computergroove Posted May 19, 2014 Posted May 19, 2014 I am revamping an old script I made several years ago and I am having a few problems I cannot fix. When started, the script is supposed to randomly play videos located in the @ScriptDirVideos. While it is doing this, a gui window is waiting for a barcode to be scanned. When a barcode is scanned then the program is supposed to stop playing the video it is currently playing and start playing the video file associated with the barcode. It needs to do this even when the script is playing a scanned video. A couple of issues I am having: 1. I scan a barcode and a video starts to play. When I scan another barcode the video playing does not stop and the new video that is supposed to play does not play. 2. The _PlayRandom function does not actually play any videos. It shows the video player splash screen for a quick second and then goes back to the waiting for user input screen. *The script is using Media Player Classic www.MPC-HC.com. All the video files are going to be MPG. The script needs to run for over 24 hours at a time without crashing. expandcollapse popup#include <GUIConstants.au3> #include <string.au3> #Include <File.au3> #Include <Array.au3> Global $AviList = _FileListToArray(@ScriptDir & "\Videos","*.mpg") HotKeySet("{ESC}", "Terminate") ;Ties the exit program function to the ESC key $timer = TimerInit() ;Returns a timestamp (in milliseconds) for playing videos randomly $Form1 = GUICreate("Video Player",1100,800,0,0,$WS_MAXIMIZE);$WS_EX_TOPMOST) $edit_field = GUICtrlCreateInput("", 200, 200, 0, -200); ( "text", left, top , width , height) GUISetState(@SW_SHOW) ;sets window to show even while not playing a file on program startup GUISetBkColor(0x000000) ; sets background on GUI window GUISetState() _PlayRandom While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE FileClose(@ScriptDir & "\" & "Videos.ini") FileDelete(@ScriptDir & "\" & "Videos.ini") Exit Case $edit_field $user_input = GUICtrlRead($edit_field) If IniRead("Videos.ini", "Videos", $user_input, "no entry") = "no entry" Then MsgBox(16, "Code not found", "The Barcode you entered "&$user_input&" does not have a video.",2) WinActivate("Video Player") GUICtrlSetData($edit_field, "") Else $video_file = (@ScriptDir & "\Videos\" & IniRead("Videos.ini", "Videos", $user_input, "no entry")) GUICtrlSetData($edit_field, "") WinActivate("Video Player") Run (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close "&$video_file&"") EndIf EndSwitch If TimerDiff($timer) > 20000 Then _PlayRandom() EndIf WEnd Func _PlayRandom() Local $ArrayNumber Local $RandomArrayNo $ArrayNumber=$AviList[0] $RandomArrayNo = Random(2,$ArrayNumber) RunWait (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close "&$AviList[$RandomArrayNo]&"") _PlayRandom() EndFunc Any suggestions are appreciated. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
jguinch Posted May 19, 2014 Posted May 19, 2014 You can kill the MPClassic process to stop the video, then play an other one... ProcessClose("mpc-hc64.exe") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
JohnOne Posted May 19, 2014 Posted May 19, 2014 _PlayRandom Error: no () AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
computergroove Posted May 19, 2014 Author Posted May 19, 2014 I want the scanned video to play until it is done or until a new barcode is scanned, have my script detect that the program is closed (hence the /close command parameter) and start playing random videos 20 seconds after the scanned video has finished playing. @JohnOne thanks I did miss that. The PlayRandom function is not working properly. I know I cannot read an array to a msgbox but I cannot find good documentation for _ArrayDisplay to know how to output it to screen for troubleshooting. Any suggestions? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
computergroove Posted May 19, 2014 Author Posted May 19, 2014 Else $video_file = (@ScriptDir & "\Videos\" & IniRead("Videos.ini", "Videos", $user_input, "no entry")) GUICtrlSetData($edit_field, "") Run (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close "&$video_file&"") WinActivate("Video Player") From here do I need to add another GuiCtrlRead or can I have the program continue to listen to the first instance? I want to play the video then activate the scanning window and listen for a new barcode scan. I understand the logic of what I want to do but I dont know the syntax. Help me out here. If GUICtrlRead >0 then ProcessClose("mpc-hc64.exe") Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
computergroove Posted May 19, 2014 Author Posted May 19, 2014 I think this might work actually. Trying it now. Else $video_file = (@ScriptDir & "\Videos\" & IniRead("Videos.ini", "Videos", $user_input, "no entry")) GUICtrlSetData($edit_field, "");erases input in gui window ProcessClose("mpc-hc64.exe") Run (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close "&$video_file&"") WinActivate("Video Player" Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now