#include #include #include Opt("GUIOnEventMode", 1) Global Enum $PREG_PLROBJ, $PREG_IIPOBJ, $PREG_CID, $PREG_POS, $PREG_MAX Global $aPlayerReg[$PREG_MAX] Global Enum $CREG_PLAYPAUSE, $CREG_STOP, $CREG_RW, $CREG_FF, _ $CREG_PREVIOUS, $CREG_NEXT, $CREG_MUTE, $CREG_LOOP, $CREG_SHUF, _ $CREG_VOL, $CREG_TRANSPORT, $CGRG_FULLSCREEN, $CREG_PLAYLIST, $CREG_MAX Global $aCtrlReg[$CREG_MAX] Global Enum $PLYST_UNDEFINED = 0, $PLYST_STOPPED, $PLYST_PAUSED, _ $PLYST_PLAYING, $PLYST_FASTFWD, $PLYST_REWIND, $PLYST_BUFFERING, _ $PLYST_WAITING, $PLYST_MEDIA_ENDED, $PLYST_TRANSITIONING, $PLYST_READY, _ $PLYST_RECONNECTING Global Enum $OPNST_UNDEFINED = 0, $OPNST_PL_CHANGING, $OPNST_PL_LOCATING, _ $OPNST_PL_CONNECTING, $OPNST_PL_LOADING, $OPNST_PL_OPENING, _ $OPNST_PL_OPEN_NO_MEDIA, $OPNST_CHANGED, $OPNST_MED_CHANGING, _ $OPNST_MED_LOCATING, $OPNST_MED_CONNECTING, $OPNST_MED_LOADING, _ $OPNST_MED_OPENING, $OPNST_MED_OPEN, $OPNST_CODEC_BEGIN_ACQ, _ $OPNST_CODEC_END_ACQ, $OPNST_LIC_BEGIN_ACQ, $OPNST_LIC_END_ACQ, _ $OPNST_INDIV_BEGIN, $OPNST_INDIV_END, $OPNST_MED_WAITING, _ $OPNST_OPENING_UNKNOWN_URL Global Enum $PLCHG_UNKNOWN = 0, $PLCHG_CLEAR, $PLCHG_INFO, _ $PLCHG_MOVE, $PLCHG_DELETE, $PLCHG_INSERT, $PLCHG_APPEND, _ $PLCHG_NAME = 8, $PLCHG_SORT = 10 Func _MP_Create($ix, $iy, $iw, $ih) Local $oWMP, $aRect[4] = [$ix, $iy, $iw, $ih] $oWMP = ObjCreate("WMPlayer.OCX") $aPlayerReg[$PREG_PLROBJ] = $oWMP $aPlayerReg[$PREG_IIPOBJ] = __MP_CreateInPlaceObjInterface() $aPlayerReg[$PREG_CID] = GUICtrlCreateObj($oWMP, $ix, $iy, $iw, $ih) $aPlayerReg[$PREG_POS] = $aRect __MP_SetPos() $oWMP.WindowlessVideo = False $oWMP.UIMode = "none" $oWMP.EnableContextMenu = False $oWMP.StretchToFit = True $oWMP.Settings.AutoStart = False $oWMP.Settings.EnableErrorDialogs = False ObjEvent($oWMP, "__MPCB_") Return $oWMP EndFunc ;==>_MP_Create Func _MP_Resize($ix, $iy, $iw, $ih) Local $hCtrl, $aRect[4] = [$ix, $iy, $iw, $ih] $hCtrl = $aPlayerReg[$PREG_CID] $aPlayerReg[$PREG_POS] = $aRect GUICtrlSetPos($hCtrl, $ix, $iy, $iw, $ih) __MP_SetPos() EndFunc ;==>_MP_Resize Func _MP_LoadMedia($sPath) Local $oWMP $oWMP = $aPlayerReg[$PREG_PLROBJ] $oWMP.Url = $sPath EndFunc ;==>_MP_LoadMedia Func _MP_CtrlCreatePlayPause($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateButton("", $ix, $iy, $iw, $ih) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_PLAYPAUSE] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_PlayPause") __MP_UpdatePlayPause() Return $hCtrl EndFunc ;==>_MP_CtrlCreatePlayPause Func _MP_CtrlCreateStop($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateButton("", $ix, $iy, $iw, $ih) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_STOP] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Stop") __MP_UpdateStop() Return $hCtrl EndFunc ;==>_MP_CtrlCreateStop Func _MP_CtrlCreateFastFwd($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateCheckbox("", $ix, $iy, $iw, $ih, $BS_PUSHLIKE) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_FF] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_FastFwd") __MP_UpdateFastFwd() Return $hCtrl EndFunc ;==>_MP_CtrlCreateFastFwd Func _MP_CtrlCreateRewind($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateCheckbox("", $ix, $iy, $iw, $ih, $BS_PUSHLIKE) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_RW] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Rewind") __MP_UpdateRewind() Return $hCtrl EndFunc ;==>_MP_CtrlCreateRewind Func _MP_CtrlCreateNext($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateButton("", $ix, $iy, $iw, $ih) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_NEXT] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Next") __MP_UpdateNext() Return $hCtrl EndFunc ;==>_MP_CtrlCreateNext Func _MP_CtrlCreatePrevious($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateButton("", $ix, $iy, $iw, $ih) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_PREVIOUS] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Previous") __MP_UpdatePrevious() Return $hCtrl EndFunc ;==>_MP_CtrlCreatePrevious Func _MP_CtrlCreateShuffle($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateCheckbox("", $ix, $iy, $iw, $ih, $BS_PUSHLIKE) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_SHUF] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Shuffle") __MP_UpdateShuffle() Return $hCtrl EndFunc ;==>_MP_CtrlCreateShuffle Func _MP_CtrlCreateLoop($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateCheckbox("", $ix, $iy, $iw, $ih, $BS_PUSHLIKE) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_LOOP] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Loop") __MP_UpdateLoop() Return $hCtrl EndFunc ;==>_MP_CtrlCreateLoop Func _MP_CtrlCreateMute($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateCheckbox("", $ix, $iy, $iw, $ih, $BS_PUSHLIKE) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CREG_MUTE] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Mute") __MP_UpdateMute() Return $hCtrl EndFunc ;==>_MP_CtrlCreateMute Func _MP_CtrlCreateTransport($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateSlider($ix, $iy, $iw, $ih, $TBS_BOTH) GUICtrlSetLimit($hCtrl, 0, 0) $aCtrlReg[$CREG_TRANSPORT] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Transport") Return $hCtrl EndFunc ;==>_MP_CtrlCreateTransport Func _MP_CtrlCreateVolume($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateSlider($ix, $iy, $iw, $ih, $TBS_BOTTOM) GUICtrlSetLimit($hCtrl, 100) $aCtrlReg[$CREG_VOL] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Volume") __MP_UpdateVolume() Return $hCtrl EndFunc ;==>_MP_CtrlCreateVolume Func _MP_CtrlCreateFullScreen($ix, $iy, $iw, $ih) Local $hCtrl $hCtrl = GUICtrlCreateCheckbox("", $ix, $iy, $iw, $ih, $BS_PUSHLIKE) GUICtrlSetFont($hCtrl, 12, -1, -1, "webdings") $aCtrlReg[$CGRG_FULLSCREEN] = $hCtrl GUICtrlSetOnEvent($hCtrl, "_MP_Fullscreen") __MP_UpdateFullScreen() Return $hCtrl EndFunc ;==>_MP_CtrlCreateFullScreen Func _MP_CtrlCreatePlaylist($ix, $iy, $iw, $ih) Local $hCtrl Local $iStyle, $iExStyle $iStyle = BitOR($LVS_SINGLESEL, $LVS_NOCOLUMNHEADER) $iExStyle = BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE) $hCtrl = GUICtrlCreateListView("Playlist", $ix, $iy, $iw, $ih, $iStyle, $iExStyle) GUICtrlSetState($hCtrl, BitOR($GUI_DROPACCEPTED, $GUI_ENABLE)) $aCtrlReg[$CREG_PLAYLIST] = $hCtrl _GUICtrlListView_SetColumnWidth($hCtrl, 0, $iw) Return $hCtrl EndFunc ;==>_MP_CtrlCreatePlaylist Func _MP_PlaylistAdd($sPath) Local $oWMP, $oItem $oWMP = $aPlayerReg[$PREG_PLROBJ] $oItem = $oWMP.NewMedia($sPath) $oWMP.CurrentPlayList.AppendItem($oItem) EndFunc ;==>_MP_PlaylistAdd Func _MP_PlayPause() Local $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Controls.IsAvailable("play") Then $oWMP.Controls.Play() ElseIf $oWMP.Controls.IsAvailable("pause") Then $oWMP.Controls.Pause() EndIf EndFunc ;==>_MP_PlayPause Func _MP_Stop() Local $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Controls.IsAvailable("stop") Then $oWMP.Controls.Stop() EndFunc ;==>_MP_Stop Func _MP_FastFwd() Local $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.PlayState = $PLYST_FASTFWD Then _MP_PlayPause() ElseIf $oWMP.Controls.IsAvailable("fastForward") Then $oWMP.Controls.FastForward() EndIf EndFunc ;==>_MP_FastFwd Func _MP_Rewind() Local $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.PlayState = $PLYST_REWIND Then _MP_PlayPause() ElseIf $oWMP.Controls.IsAvailable("fastReverse") Then $oWMP.Controls.FastReverse() EndIf EndFunc ;==>_MP_Rewind Func _MP_Next() Local $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Controls.IsAvailable("next") Then $oWMP.Controls.Next() EndFunc ;==>_MP_Next Func _MP_Previous() Local $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Controls.IsAvailable("previous") Then $oWMP.Controls.Previous() EndFunc ;==>_MP_Previous Func _MP_Shuffle() Local $oWMP, $iState $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Settings.IsAvailable("SetMode") Then $iState = $oWMP.Settings.GetMode("shuffle") $oWMP.Settings.SetMode("shuffle", Not $iState) EndIf EndFunc ;==>_MP_Shuffle Func _MP_Loop() Local $oWMP, $iState $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Settings.IsAvailable("SetMode") Then $iState = $oWMP.Settings.GetMode("loop") $oWMP.Settings.SetMode("loop", Not $iState) EndIf EndFunc ;==>_MP_Loop Func _MP_Transport() Local $hCtrl, $oWMP $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_TRANSPORT] $oWMP.Controls.CurrentPosition = GUICtrlRead($hCtrl) EndFunc ;==>_MP_Transport Func _MP_Volume() Local $hCtrl, $oWMP $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_VOL] $oWMP.Settings.Volume = GUICtrlRead($hCtrl) __MP_UpdateMute() EndFunc ;==>_MP_Volume Func _MP_Mute() Local $oWMP, $iState $oWMP = $aPlayerReg[$PREG_PLROBJ] If $oWMP.Settings.IsAvailable("Mute") Then $iState = $oWMP.Settings.Mute $oWMP.Settings.Mute = Not $iState EndIf EndFunc ;==>_MP_Mute Func _MP_Fullscreen() Local $oWMP, $iState $oWMP = $aPlayerReg[$PREG_PLROBJ] $iState = $oWMP.FullScreen $oWMP.FullScreen = Not $iState __MP_UpdateFullScreen() EndFunc ;==>_MP_Fullscreen Func _MP_PlaylistSelItem($iIndex) Local $oWMP, $oPlaylist $oWMP = $aPlayerReg[$PREG_PLROBJ] $oPlaylist = $oWMP.CurrentPlaylist $oWMP.Controls.CurrentItem = $oPlaylist.Item($iIndex) EndFunc ;==>_MP_PlaylistSelItem Func __MP_PlaylistSelItem() Local $iSelItem, $hCtrl $hCtrl = $aCtrlReg[$CREG_PLAYLIST] $iSelItem = Int(_GUICtrlListView_GetSelectedIndices($hCtrl)) _GUICtrlListView_SetItemSelected($hCtrl, $iSelItem, False, False) _MP_PlaylistSelItem($iSelItem) EndFunc ;==>__MP_PlaylistSelItem Func __MP_UpdatePlayPause() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel Local $sLabPlay = "4", $sLabPause = ";" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_PLAYPAUSE] $iLastState = GUICtrlGetState($hCtrl) $sLastLabel = GUICtrlRead($hCtrl) If $oWMP.Controls.IsAvailable("play") Then If $sLastLabel <> $sLabPlay Then GUICtrlSetData($hCtrl, $sLabPlay) If Not BitAND($GUI_ENABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_ENABLE) ElseIf $oWMP.Controls.IsAvailable("pause") Then If $sLastLabel <> $sLabPause Then GUICtrlSetData($hCtrl, $sLabPause) If Not BitAND($GUI_ENABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_ENABLE) Else If $sLastLabel <> $sLabPlay Then GUICtrlSetData($hCtrl, $sLabPlay) If Not BitAND($GUI_DISABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_DISABLE) EndIf EndFunc ;==>__MP_UpdatePlayPause Func __MP_UpdateStop() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel Local $sLabel = "<" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_STOP] $iLastState = GUICtrlGetState($hCtrl) $sLastLabel = GUICtrlRead($hCtrl) If Not $sLastLabel Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) If $oWMP.Controls.IsAvailable("stop") Then If Not BitAND($GUI_ENABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_ENABLE) Else If Not BitAND($GUI_DISABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_DISABLE) EndIf EndFunc ;==>__MP_UpdateStop Func __MP_UpdateFastFwd() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel, $iNewState Local $sLabel = "8" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_FF] $iLastState = GUICtrlGetState($hCtrl) $sLastLabel = GUICtrlRead($hCtrl, $GUI_READ_EXTENDED) If Not $sLastLabel Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) If $oWMP.Controls.IsAvailable("fastForward") Then $iNewState = $GUI_ENABLE Else $iNewState = $GUI_DISABLE EndIf If $oWMP.PlayState = $PLYST_FASTFWD Then $iNewState = BitOR($iNewState, $GUI_CHECKED) Else $iNewState = BitOR($iNewState, $GUI_UNCHECKED) EndIf If $iLastState <> $iNewState Then GUICtrlSetState($hCtrl, $iNewState) EndFunc ;==>__MP_UpdateFastFwd Func __MP_UpdateRewind() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel, $iNewState Local $sLabel = "7" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_RW] $iLastState = GUICtrlGetState($hCtrl) $sLastLabel = GUICtrlRead($hCtrl, $GUI_READ_EXTENDED) If Not $sLastLabel Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) If $oWMP.Controls.IsAvailable("fastReverse") Then $iNewState = $GUI_ENABLE Else $iNewState = $GUI_DISABLE EndIf If $oWMP.PlayState = $PLYST_REWIND Then $iNewState = BitOR($iNewState, $GUI_CHECKED) Else $iNewState = BitOR($iNewState, $GUI_UNCHECKED) EndIf If $iLastState <> $iNewState Then GUICtrlSetState($hCtrl, $iNewState) EndFunc ;==>__MP_UpdateRewind Func __MP_UpdateNext() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel Local $sLabel = ":" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_NEXT] $iLastState = GUICtrlGetState($hCtrl) $sLastLabel = GUICtrlRead($hCtrl) If Not $sLastLabel Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) If $oWMP.Controls.IsAvailable("next") Then If Not BitAND($GUI_ENABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_ENABLE) Else If Not BitAND($GUI_DISABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_DISABLE) EndIf EndFunc ;==>__MP_UpdateNext Func __MP_UpdatePrevious() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel Local $sLabel = "9" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_PREVIOUS] $iLastState = GUICtrlGetState($hCtrl) $sLastLabel = GUICtrlRead($hCtrl) If Not $sLastLabel Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) If $oWMP.Controls.IsAvailable("previous") Then If Not BitAND($GUI_ENABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_ENABLE) Else If Not BitAND($GUI_DISABLE, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_DISABLE) EndIf EndFunc ;==>__MP_UpdatePrevious Func __MP_UpdateShuffle() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel, $iNewState Local $sLabel = "q" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_SHUF] $iLastState = GUICtrlGetState($hCtrl) $iLastState = BitOR($iLastState, GUICtrlRead($hCtrl)) $sLastLabel = GUICtrlRead($hCtrl, $GUI_READ_EXTENDED) If Not $sLastLabel Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) EndIf If $oWMP.Settings.IsAvailable("SetMode") Then $iNewState = $GUI_ENABLE Else $iNewState = $GUI_DISABLE EndIf If $oWMP.Settings.GetMode("shuffle") Then $iNewState = BitOR($iNewState, $GUI_CHECKED) Else $iNewState = BitOR($iNewState, $GUI_UNCHECKED) EndIf If $iLastState <> $iNewState Then GUICtrlSetState($hCtrl, $iNewState) EndFunc ;==>__MP_UpdateShuffle Func __MP_UpdateLoop() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel, $iNewState Local $sLabel = "`" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_LOOP] $iLastState = GUICtrlGetState($hCtrl) $iLastState = BitOR($iLastState, GUICtrlRead($hCtrl)) $sLastLabel = GUICtrlRead($hCtrl, $GUI_READ_EXTENDED) If IsInt($sLastLabel) Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) EndIf If $oWMP.Settings.IsAvailable("SetMode") Then $iNewState = $GUI_ENABLE Else $iNewState = $GUI_DISABLE EndIf If $oWMP.Settings.GetMode("loop") Then $iNewState = BitOR($iNewState, $GUI_CHECKED) Else $iNewState = BitOR($iNewState, $GUI_UNCHECKED) EndIf If $iLastState <> $iNewState Then GUICtrlSetState($hCtrl, $iNewState) EndFunc ;==>__MP_UpdateLoop Func __MP_ResetTransport() Local $oWMP, $hCtrl, $iDuration = 0 $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_TRANSPORT] If $oWMP.OpenState = $OPNST_MED_OPEN Then $iDuration = $oWMP.CurrentMedia.Duration EndIf GUICtrlSetLimit($hCtrl, $iDuration) EndFunc ;==>__MP_ResetTransport Func __MP_UpdateTransport() Local $oWMP, $hCtrl $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_TRANSPORT] ;Nasty Solution!! Don't Update slider while (potentially) trying to control it If _IsPressed("01") Then Return If _IsPressed("25") Then Return If _IsPressed("26") Then Return If _IsPressed("27") Then Return If _IsPressed("28") Then Return GUICtrlSetData($hCtrl, $oWMP.Controls.CurrentPosition) EndFunc ;==>__MP_UpdateTransport Func __MP_UpdateVolume() Local $oWMP, $hCtrl $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_VOL] GUICtrlSetData($hCtrl, $oWMP.Settings.Volume) EndFunc ;==>__MP_UpdateVolume Func __MP_UpdateMute() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel, $iNewState Local $sLabel = "X" $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CREG_MUTE] $iLastState = GUICtrlGetState($hCtrl) $iLastState = BitOR($iLastState, GUICtrlRead($hCtrl)) $sLastLabel = GUICtrlRead($hCtrl, $GUI_READ_EXTENDED) If IsInt($sLastLabel) Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) EndIf If $oWMP.Settings.IsAvailable("Mute") Then $iNewState = $GUI_ENABLE Else $iNewState = $GUI_DISABLE EndIf If $oWMP.Settings.Mute Then $iNewState = BitOR($iNewState, $GUI_CHECKED) Else $iNewState = BitOR($iNewState, $GUI_UNCHECKED) EndIf If $iLastState <> $iNewState Then GUICtrlSetState($hCtrl, $iNewState) EndFunc ;==>__MP_UpdateMute Func __MP_UpdateFullScreen() Local $oWMP, $hCtrl Local $iLastState, $sLastLabel Local $sLabel = "1" Static $fAdLib = False $oWMP = $aPlayerReg[$PREG_PLROBJ] $hCtrl = $aCtrlReg[$CGRG_FULLSCREEN] $iLastState = GUICtrlGetState($hCtrl) $iLastState = BitOR($iLastState, GUICtrlRead($hCtrl)) $sLastLabel = GUICtrlRead($hCtrl, $GUI_READ_EXTENDED) If IsInt($sLastLabel) Then $sLastLabel = "" If $sLastLabel <> $sLabel Then GUICtrlSetData($hCtrl, $sLabel) EndIf If $oWMP.FullScreen Then If Not BitAND($GUI_CHECKED, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_CHECKED) If Not $fAdLib Then AdlibRegister("__MP_UpdateFullScreen", 500) $fAdLib = True EndIf Else If Not BitAND($GUI_UNCHECKED, $iLastState) Then GUICtrlSetState($hCtrl, $GUI_UNCHECKED) If $fAdLib Then AdlibUnRegister("__MP_UpdateFullScreen") $fAdLib = False EndIf EndIf EndFunc ;==>__MP_UpdateFullScreen Func __MP_UpdatePlayList() Local $oWMP, $oPlaylist, $hCtrl, $oMedia Local $iLVCount, $sCurTitle $oWMP = $aPlayerReg[$PREG_PLROBJ] $oPlaylist = $oWMP.CurrentPlaylist $hCtrl = $aCtrlReg[$CREG_PLAYLIST] If Not $hCtrl Then Return $iLVCount = _GUICtrlListView_GetItemCount($hCtrl) _GUICtrlListView_BeginUpdate($hCtrl) If Not $oPlaylist.Count Then _GUICtrlListView_DeleteAllItems($hCtrl) Else For $i = 0 To $oPlaylist.Count - 1 $oMedia = $oPlaylist.Item($i) $sCurTitle = $oMedia.Name If $i < $iLVCount Then If $sCurTitle <> _GUICtrlListView_GetItemText($hCtrl, $i) Then _GUICtrlListView_SetItemText($hCtrl, $i, $sCurTitle) EndIf Else GUICtrlCreateListViewItem($sCurTitle, $hCtrl) GUICtrlSetOnEvent(-1, "__MP_PlaylistSelItem") EndIf Next For $i = $iLVCount - 1 To $oPlaylist.Count Step -1 _GUICtrlListView_DeleteItem($hCtrl, $i) Next EndIf _GUICtrlListView_EndUpdate($hCtrl) EndFunc ;==>__MP_UpdatePlayList Func __MP_UpdatePlayListCurItem() Local $oWMP, $oPlaylist, $hCtrl, $oMedia Local $iTestIdx, $iNewItem, $hLVItem Static $iLastItem = -1 $oWMP = $aPlayerReg[$PREG_PLROBJ] $oPlaylist = $oWMP.CurrentPlaylist $hCtrl = $aCtrlReg[$CREG_PLAYLIST] If Not $oPlaylist.Count Then $iLastItem = -1 Return EndIf If $oPlaylist.Count <> _GUICtrlListView_GetItemCount($hCtrl) Then __MP_UpdatePlayList() EndIf For $i = 0 To $oPlaylist.Count - 1 $iTestIdx = Mod(($iLastItem + 1) + $i, $oPlaylist.Count) $oMedia = $oPlaylist.Item($iTestIdx) If $oMedia.IsIdentical($oWMP.CurrentMedia()) Then ExitLoop Next If $i = $oPlaylist.Count Then Return $iNewItem = $iTestIdx If $iNewItem <> $iLastItem Then If $iLastItem >= 0 Then $hLVItem = _GUICtrlListView_GetItemParam($hCtrl, $iLastItem) GUICtrlSetColor($hLVItem, 0) EndIf $hLVItem = _GUICtrlListView_GetItemParam($hCtrl, $iNewItem) GUICtrlSetColor($hLVItem, 0X0000AA) EndIf If $oMedia.Name <> _GUICtrlListView_GetItemText($hCtrl, $iNewItem) Then _GUICtrlListView_SetItemText($hCtrl, $iNewItem, $oMedia.Name) EndIf $iLastItem = $iNewItem EndFunc ;==>__MP_UpdatePlayListCurItem Func __MPCB_StatusChange() ;~ ConsoleWrite("StatCh: " & $aPlayerReg[$PREG_PLROBJ].status & @CRLF) EndFunc ;==>__MPCB_StatusChange Func __MPCB_OpenStateChange($iNewState) ;~ ConsoleWrite("openState: " & $iNewState & @CRLF) ;~ Local $oWMP = $aPlayerReg[$PREG_PLROBJ] Switch $iNewState Case $OPNST_MED_OPEN __MP_ResetTransport() EndSwitch EndFunc ;==>__MPCB_OpenStateChange Func __MPCB_PlayStateChange($iNewState) ;~ ConsoleWrite("playState: " & $iNewState & @CRLF) Switch $iNewState Case $PLYST_PLAYING AdlibRegister("__MP_UpdateTransport", 1000) Case $PLYST_STOPPED, $PLYST_PAUSED AdlibUnRegister("__MP_UpdateTransport") __MP_UpdateFullScreen() EndSwitch __MP_UpdateTPControls() __MP_SetPos() EndFunc ;==>__MPCB_PlayStateChange Func __MPCB_ModeChange($sMode, $iValue) #forceref $sMode, $iValue ;~ ConsoleWrite("modeChange: " & $sMode & ": " & $iValue & @CRLF) Switch $sMode Case "shuffle" __MP_UpdateShuffle() Case "loop" __MP_UpdateLoop() EndSwitch EndFunc ;==>__MPCB_ModeChange Func __MPCB_PlaylistChange($oPlaylist, $sChange) #forceref $oPlaylist, $sChange __MP_UpdatePlayList() EndFunc ;==>__MPCB_PlaylistChange Func __MPCB_MediaChange($oMedia) #forceref $oMedia __MP_UpdatePlayListCurItem() EndFunc ;==>__MPCB_MediaChange Func __MPCB_CurrentItemChange() __MP_UpdatePlayListCurItem() EndFunc ;==>__MPCB_CurrentItemChange Func __MP_UpdateTPControls() __MP_UpdatePlayPause() __MP_UpdateStop() __MP_UpdateFastFwd() __MP_UpdateRewind() __MP_UpdatePrevious() __MP_UpdateNext() __MP_UpdateTransport() EndFunc ;==>__MP_UpdateTPControls Func __MP_CreateInPlaceObjInterface() Local $oWMP, $oIInPlaceObj, $tagIOleInPlaceObj $oWMP = $aPlayerReg[$PREG_PLROBJ] $tagIOleInPlaceObj = _ "ContextSensitiveHelp none(int); " & _ "GetWindow none(ptr); " & _ "InPlaceDeactivate none(); " & _ "ReactivateAndUndo none(); " & _ "SetObjectRects none(ptr; ptr;); " & _ "UIDeactivate none();" $oIInPlaceObj = ObjCreateInterface($oWMP, "{00000113-0000-0000-C000-000000000046}", $tagIOleInPlaceObj) If Not IsObj($oIInPlaceObj) Then Return SetError(1, False) Return $oIInPlaceObj EndFunc ;==>__MP_CreateInPlaceObjInterface Func __MP_SetPos() Local $oIInPlaceObj, $aRect, $tRect, $pRect $oIInPlaceObj = $aPlayerReg[$PREG_IIPOBJ] $aRect = $aPlayerReg[$PREG_POS] $tRect = DllStructCreate("int[4]") $pRect = DllStructGetPtr($tRect) For $i = 1 To 4 DllStructSetData($tRect, 1, $aRect[$i - 1], $i) Next $oIInPlaceObj.SetObjectRects($pRect, $pRect) EndFunc ;==>__MP_SetPos