#include #include #Include #include "WMP_Sudeep.au3" Opt("GUIOnEventMode", 1) ; Change to OnEvent mode _WMPErrorHandlerRegister() Global $wmp Global $wmpSeek_drag = False $wmpForm = GUICreate("Windows Media Player Example", 950, 550, -1, -1, $WS_MAXIMIZEBOX ) $wmp = _GUICtrlWMP_Create(10, 10, 800, 450, True) $wmpState = GUICtrlCreateLabel ("", 815, 10, 100, 30) $wmpLoad = GUICtrlCreateButton("Load", 815, 45, 100, 30) $wmpPlay = GUICtrlCreateButton("Play", 815, 80, 100, 30) $wmpRR = GUICtrlCreateButton("<<", 815, 115, 50, 30) $wmpFF = GUICtrlCreateButton(">>", 865, 115, 50, 30) $wmpStop = GUICtrlCreateButton("Stop", 815, 150, 100, 30) $wmpMute = GUICtrlCreateButton("Mute", 815, 185, 100, 30) $wmpVol = GUICtrlCreateSlider(815, 220, 100, 30) GUICtrlSetLimit($wmpVol, 100) GUICtrlSetData($wmpVol, _GUICtrlWMP_Action($wmp, "volume")) $wmpTime = GUICtrlCreateLabel("", 815, 255, 100, 30) $wmpSeek = GUICtrlCreateSlider(5, 460, 800, 30, $TBS_NOTICKS) GUISetOnEvent($GUI_EVENT_CLOSE, "appClose") GUICtrlSetOnEvent($wmpLoad, "load") GUICtrlSetOnEvent($wmpPlay, "play") GUICtrlSetOnEvent($wmpRR, "moveFast") GUICtrlSetOnEvent($wmpFF, "moveFast") GUICtrlSetOnEvent($wmpStop, "stop") GUICtrlSetOnEvent($wmpMute, "mute") GUICtrlSetOnEvent($wmpVol, "volume") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 ; Update the Play State Label $pState = _GUICtrlWMP_Action($wmp, "state") GUICtrlSetData($wmpState, $pState) If $pState = "Playing" And $wmpSeek_drag = False Then GUICtrlSetData($wmpSeek, _GUICtrlWMP_Action($wmp, "position")) GUICtrlSetData($wmpTime, "Time : " & _GUICtrlWMP_Action($wmp, "positionstring")) $wmpSeek_drag = False EndIf Sleep(100) WEnd Func load() $filePath = FileOpenDialog("Select Video File...", "", "Video files (*.avi;*.mp4;*.mpg)") _GUICtrlWMP_Load($wmp, $filePath, False) EndFunc Func play() If GUICtrlRead($wmpPlay) = "Play" Then _GUICtrlWMP_Action($wmp, "play") While _GUICtrlWMP_Action($wmp, "duration") <= 0 Sleep(100) Wend GUICtrlSetLimit($wmpSeek, _GUICtrlWMP_Action($wmp, "duration")) $wmpSeek_drag = False GUICtrlSetData($wmpPlay, "Pause") Else _GUICtrlWMP_Action($wmp, "pause") GUICtrlSetData($wmpPlay, "Play") EndIf EndFunc Func moveFast() If @GUI_CtrlId = $wmpRR Then _GUICtrlWMP_Action($wmp, "fastReverse") Elseif @GUI_CtrlId = $wmpFF Then _GUICtrlWMP_Action($wmp, "fastForward") EndIf EndFunc Func stop() _GUICtrlWMP_Action($wmp, "stop") EndFunc Func mute() If GUICtrlRead($wmpMute) = "Mute" Then _GUICtrlWMP_Action($wmp, "mute") GUICtrlSetData($wmpMute, "UnMute") Else _GUICtrlWMP_Action($wmp, "unmute") GUICtrlSetData($wmpMute, "Mute") EndIf EndFunc Func volume() $vol = GUICtrlRead($wmpVol) _GUICtrlWMP_Action($wmp, "volume", $vol) EndFunc Func appClose() Exit EndFunc ;==>appClose Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndSlider $hWndSlider = $wmpSeek If Not IsHWnd($wmpSeek) Then $hWndSlider = GUICtrlGetHandle($wmpSeek) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndSlider Switch $iCode case $NM_CUSTOMDRAW $wmpSeek_drag = True Case $NM_RELEASEDCAPTURE _GUICtrlWMP_Action($wmp, "position", GUICtrlRead($wmpSeek)) $wmpSeek_drag = False EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc