Sign in to follow this  
Followers 0
peter1234

Play media function mostly works but I need some expert level help

4 posts in this topic

This is only my second AutoIt project so I still have a lot to learn and I need some expert help with this. Try it. Just copy posted code and run. It works great for audio. But, if any key is pressed while a video is playing full screen, the video window disappears. The video is still playing and the function will terminate properly at end of video file or if ESC button is pushed. But the full screen video window is not visable.

Is there a command I can use to keep the full screen video window visable? Or else, is there a command I can keep calling to constantly restore the full screen video window? The function works (but has a different problem) if video is not played using full screen. However, I want the video to play full screen. Any help or comments will be appreciated. Thanks.

I plan on having two versions. One for single play and one for repeat play. The only difference is one line of code.

;***************************************************
;   start of usage example for: PLAY_MEDIA_FUNC 
;***************************************************
#include <GuiConstants.au3>
$Play_Media_FUNC_file=GetFile() ;<<<<<< get a file name to input into FUNC
Play_Media_FUNC($Play_Media_FUNC_file) ;<<<<<<< call PLAY_MEDIA_FUNC 
MsgBox(0, "", "PLAY_MEDIA_FUNC returned to calling script") ;<<<<< just to show FUNC returned to script
EXIT

FUNC GetFile()  ;<<<<<< just a function to get a file name
$file=""
$return = FileOpenDialog ( "Open a file to play - press ESC to stop playing", "", "All (*.*)"   )  
IF @error<>1 then 
  $file=$return
EndIf
Return($file)
EndFunc
;***************************************************
;   end of usage example for: PLAY_MEDIA_FUNC 
;***************************************************


;*********************************
;   start of: PLAY_MEDIA_FUNC 
;*********************************
FUNC Play_Media_FUNC ($Play_Media_FUNC_file)
If $Play_Media_FUNC_file = "" then Return
HotKeySet("{ESC}", "Play_Media_FUNC_Terminate")
Global $Play_Media_FUNC_Terminate=0
mciSendString("Open " & '"'&$Play_Media_FUNC_file&'"' &  " alias MediaFile" )  
mciSendString("Play MediaFile fullscreen repeat")  
mciSendString("Set MediaFile time format milliseconds")
$Play_Media_FUNC_TimeStop = mciSendString("Status MediaFile length")
$Play_Media_FUNC_TimeStart = TimerInit()
While $Play_Media_FUNC_Terminate=0
  $Play_Media_FUNC_TimeDiff = TimerDiff($Play_Media_FUNC_TimeStart)
  IF ($Play_Media_FUNC_TimeDiff)>($Play_Media_FUNC_TimeStop) then ExitLoop;<<<< remove for repeated play
Wend
mciSendString("Close MediaFile")
EndFunc
Func Play_Media_FUNC_Terminate()
  $Play_Media_FUNC_Terminate=1
EndFunc
Func mciSendString($string)
  Local $ret
  $ret = DllCall("winmm.dll","int","mciSendString","str",$string,"str","","int",65534,"hwnd",0)
  If Not @error Then Return $ret[2]
EndFunc
;****** comments ********
;;; only parameter passed to FUNC is complete file name of media file to play
;;; press ESC button to exit before file is finished playing
;;; plays AVI, MPG, MP3, WAV and maybe more (if proper codec is installed)
;;; NOTE - does not honor anamorphic or pulldown flags used in DVD mpeg2 files
;;; mostly copied from parts of "MEDIA PLAYER, yes, another one!" by zeroZshadow
;;; works fine for audio files, but video window disappears if any key is pressed while video is playing fullscreen
;*******************************
;   end of: PLAY_MEDIA_FUNC
;*******************************

Share this post


Link to post
Share on other sites



take a look at

1

WinSetOnTop()

2

WinSetState() ( for full screen)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks for looking. It just seems that there must be something that will restore the window. But I have no resources to look at other than the scripts that are posted on this site.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0