Aassdd Posted March 23, 2008 Share Posted March 23, 2008 (edited) I don't know where to start. I looked for some _GUICtrlListView commands but I don't know which to use and how. I looked at LIMITER's player, but it's too complicated for me. I think the way it loads a file it's programmed completely wrong. expandcollapse popup#region #AutoIt3Wrapper_icon=wmp.ico #AutoIt3Wrapper_outfile=MediaPlayer.exe #AutoIt3Wrapper_compression=3 #AutoIt3Wrapper_res_comment= #AutoIt3Wrapper_res_description= #AutoIt3Wrapper_res_fileversion=1.1.2 #AutoIt3Wrapper_res_legalcopyright=Antreas - ©2008 #endregion #NoTrayIcon #include <GUIConstants.au3> #include <GuiStatusBar.au3> #include <ExtProp.au3> #include <File.au3> #include <Sound.au3> Opt("GUICloseOnESC", 0) HotKeySet("^o", "_HotKey_Events") HotKeySet("^e", "_HotKey_Events") #region ### START Koda GUI section ### Form=d:\documents and settings\administrator\desktop\mediaplayer\mediaplayer.kxf $MediaPlayer = GUICreate("MediaPlayer", 350, 240) ; Buttons [basic controls] $Play = GUICtrlCreateButton("Play", 10, 160, 50, 30) $Pause = GUICtrlCreateButton("Pause", 70, 160, 50, 30) GUICtrlSetState(-1, $GUI_DISABLE) $Stop = GUICtrlCreateButton("Stop", 130, 160, 50, 30) GUICtrlSetState(-1, $GUI_DISABLE) ; Menu $MenuFile = GUICtrlCreateMenu("&File") $MenuOpen = GUICtrlCreateMenuItem("&Open", $MenuFile) $MenuExit = GUICtrlCreateMenuItem("E&xit", $MenuFile) $MenuHelp = GUICtrlCreateMenu("&Help") $MenuAbout = GUICtrlCreateMenuItem("&About", $MenuHelp) ; Filelist $PlayList = GUICtrlCreateListView("Artist|Album|Title|Path", 20, 50, 300, 100) ; Slider [volume] $VolumeLvl = _SoundGetMasterVolume() $VolumeLbl = GUICtrlCreateLabel("Volume: " & $VolumeLvl, 280, 165, 70, 20) $VolumeSlider = GUICtrlCreateSlider(180, 160, 100, 30, BitOR($TBS_AUTOTICKS, $TBS_TOP)) GUICtrlSetData($VolumeSlider, $VolumeLvl) ; Slider [position] $Position = GUICtrlCreateSlider(20, 10, 300, 30, BitOR($TBS_AUTOTICKS, $TBS_TOP)) ; Status bar $StatusBar = _GUICtrlStatusBar_Create($MediaPlayer) SB("No music playing") ;~ DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MediaPlayer, "int", 500, "long", 0x00080000) ;~ GUICtrlSetState($PlayList, $GUI_SHOW) GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form=d:\documents and settings\administrator\desktop\mediaplayer\mediaplayer.kxf Dim $sound Dim $szDrive, $szDir, $szFName, $szExt While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $MenuOpen Open() Case $Play Play() Case $Pause Pause() Case $Stop Stop() Case $MenuAbout MsgBox(64, "MediaPlayer", "MediaPlayer made by Antreas") Case $GUI_EVENT_CLOSE, $MenuExit ;~ DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MediaPlayer, "int", 500, "long", 0x00090000) Exit EndSwitch ; Volume slider If GUICtrlRead($VolumeSlider) <> _SoundGetMasterVolume() Then _SoundSetMasterVolume(GUICtrlRead($VolumeSlider)) GUICtrlSetData($VolumeLbl, "Volume: " & GUICtrlRead($VolumeSlider)) EndIf ; Seek slider $PosCurrent = _SoundPos($sound, 2) $PosLength = _SoundLength($sound, 2) GUICtrlSetData($Position, $PosCurrent / $PosLength * 100) WEnd Func _HotKey_Events() If Not WinActive($MediaPlayer) Then HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "_HotKey_Events") Return EndIf Switch @HotKeyPressed Case "^o" Open() Case "^e" Exit EndSwitch EndFunc ;==>_HotKey_Events Func SB($SBText) _GUICtrlStatusBar_SetText($StatusBar, "Status: " & $SBText) EndFunc ;==>SB Func Open() If _SoundStatus($sound) = "playing" Then _SoundStop($sound) $path = FileOpenDialog("Select file...", @MyDocumentsDir, "Audio Files (*.mp3;*.wav)") If Not @error Then $artist = _GetExtProperty($path, 16) $album = _GetExtProperty($path, 17) $title = _GetExtProperty($path, 10) GUICtrlCreateListViewItem($artist & "|" & $album & "|" & $title & "|" & $path, $PlayList) $sound = _SoundOpen($path) $filename = _PathSplit($path, $szDrive, $szDir, $szFName, $szExt) SB("File loaded [" & $filename[3] & "]") Else MsgBox(16, "Error", "Error code: " & @error) EndIf EndFunc ;==>Open Func Play() If Not @error And $sound <> "" Then _SoundPlay($sound) GUICtrlSetState($Play, $GUI_DISABLE) GUICtrlSetState($Pause, $GUI_ENABLE) GUICtrlSetState($Stop, $GUI_ENABLE) SB("Playing") Else MsgBox(16, "Error", "Error code: " & @error) EndIf EndFunc ;==>Play Func Pause() If _SoundStatus($sound) = "playing" Then _SoundPause($sound) GUICtrlSetState($Play, $GUI_ENABLE) GUICtrlSetState($Pause, $GUI_DISABLE) SB("Paused") EndIf EndFunc ;==>Pause Func Stop() If _SoundStatus($sound) = "playing" Or "paused" Then _SoundStop($sound) GUICtrlSetState($Play, $GUI_ENABLE) GUICtrlSetState($Pause, $GUI_DISABLE) GUICtrlSetState($Stop, $GUI_DISABLE) SB("Stopped") EndIf EndFunc ;==>Stop Edited March 23, 2008 by Aassdd Link to comment Share on other sites More sharing options...
LIMITER Posted March 23, 2008 Share Posted March 23, 2008 Here's the code (added doubleclick function) expandcollapse popup#region #AutoIt3Wrapper_icon=wmp.ico #AutoIt3Wrapper_outfile=MediaPlayer.exe #AutoIt3Wrapper_compression=3 #AutoIt3Wrapper_res_comment= #AutoIt3Wrapper_res_description= #AutoIt3Wrapper_res_fileversion=1.1.2 #AutoIt3Wrapper_res_legalcopyright=Antreas - ©2008 #endregion #NoTrayIcon #include <GUIConstants.au3> #include <GuiStatusBar.au3> #include <ExtProp.au3> #include <File.au3> #include <Sound.au3> Opt("GUICloseOnESC", 0) HotKeySet("^o", "_HotKey_Events") HotKeySet("^e", "_HotKey_Events") #region ### START Koda GUI section ### Form=d:\documents and settings\administrator\desktop\mediaplayer\mediaplayer.kxf $MediaPlayer = GUICreate("MediaPlayer", 350, 240) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Buttons [basic controls] $Play = GUICtrlCreateButton("Play", 10, 160, 50, 30) $Pause = GUICtrlCreateButton("Pause", 70, 160, 50, 30) GUICtrlSetState(-1, $GUI_DISABLE) $Stop = GUICtrlCreateButton("Stop", 130, 160, 50, 30) GUICtrlSetState(-1, $GUI_DISABLE) ; Menu $MenuFile = GUICtrlCreateMenu("&File") $MenuOpen = GUICtrlCreateMenuItem("&Open", $MenuFile) $MenuExit = GUICtrlCreateMenuItem("E&xit", $MenuFile) $MenuHelp = GUICtrlCreateMenu("&Help") $MenuAbout = GUICtrlCreateMenuItem("&About", $MenuHelp) ; Filelist $PlayList = GUICtrlCreateListView("Artist|Album|Title|Path", 20, 50, 300, 100) ; Slider [volume] $VolumeLvl = _SoundGetMasterVolume() $VolumeLbl = GUICtrlCreateLabel("Volume: " & $VolumeLvl, 280, 165, 70, 20) $VolumeSlider = GUICtrlCreateSlider(180, 160, 100, 30, BitOR($TBS_AUTOTICKS, $TBS_TOP)) GUICtrlSetData($VolumeSlider, $VolumeLvl) ; Slider [position] $Position = GUICtrlCreateSlider(20, 10, 300, 30, BitOR($TBS_AUTOTICKS, $TBS_TOP)) ; Status bar $StatusBar = _GUICtrlStatusBar_Create($MediaPlayer) SB("No music playing") ;~ DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MediaPlayer, "int", 500, "long", 0x00080000) ;~ GUICtrlSetState($PlayList, $GUI_SHOW) GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form=d:\documents and settings\administrator\desktop\mediaplayer\mediaplayer.kxf Dim $sound Dim $szDrive, $szDir, $szFName, $szExt $DoubleClicked = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $MenuOpen Open() Case $Play Play() Case $Pause Pause() Case $Stop Stop() Case $MenuAbout MsgBox(64, "MediaPlayer", "MediaPlayer made by Antreas") Case $GUI_EVENT_CLOSE, $MenuExit ;~ DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MediaPlayer, "int", 500, "long", 0x00090000) Exit EndSwitch ; Volume slider If GUICtrlRead($VolumeSlider) <> _SoundGetMasterVolume() Then _SoundSetMasterVolume(GUICtrlRead($VolumeSlider)) GUICtrlSetData($VolumeLbl, "Volume: " & GUICtrlRead($VolumeSlider)) EndIf ; Seek slider $PosCurrent = _SoundPos($sound, 2) $PosLength = _SoundLength($sound, 2) GUICtrlSetData($Position, $PosCurrent / $PosLength * 100) ;double-click If $DoubleClicked Then DoubleClickFunc() $DoubleClicked = False EndIf WEnd Func _HotKey_Events() If Not WinActive($MediaPlayer) Then HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "_HotKey_Events") Return EndIf Switch @HotKeyPressed Case "^o" Open() Case "^e" Exit EndSwitch EndFunc ;==>_HotKey_Events Func SB($SBText) _GUICtrlStatusBar_SetText($StatusBar, "Status: " & $SBText) EndFunc ;==>SB Func Open() If _SoundStatus($sound) = "playing" Then _SoundStop($sound) $path = FileOpenDialog("Select file...", @MyDocumentsDir, "Audio Files (*.mp3;*.wav)") If Not @error Then $artist = _GetExtProperty($path, 16) $album = _GetExtProperty($path, 17) $title = _GetExtProperty($path, 10) GUICtrlCreateListViewItem($artist & "|" & $album & "|" & $title & "|" & $path, $PlayList) $sound = _SoundOpen($path) $filename = _PathSplit($path, $szDrive, $szDir, $szFName, $szExt) SB("File loaded [" & $filename[3] & "]") Else MsgBox(16, "Error", "Error code: " & @error) EndIf EndFunc ;==>Open Func Play() If Not @error And $sound <> "" Then _SoundPlay($sound) GUICtrlSetState($Play, $GUI_DISABLE) GUICtrlSetState($Pause, $GUI_ENABLE) GUICtrlSetState($Stop, $GUI_ENABLE) SB("Playing") Else MsgBox(16, "Error", "Error code: " & @error) EndIf EndFunc ;==>Play Func Pause() If _SoundStatus($sound) = "playing" Then _SoundPause($sound) GUICtrlSetState($Play, $GUI_ENABLE) GUICtrlSetState($Pause, $GUI_DISABLE) SB("Paused") EndIf EndFunc ;==>Pause Func Stop() If _SoundStatus($sound) = "playing" Or "paused" Then _SoundStop($sound) GUICtrlSetState($Play, $GUI_ENABLE) GUICtrlSetState($Pause, $GUI_DISABLE) GUICtrlSetState($Stop, $GUI_DISABLE) SB("Stopped") EndIf EndFunc ;==>Stop Func DoubleClickFunc() If _SoundStatus($sound) = "playing" Then _SoundStop($sound) $dbclick1 = GUICtrlRead(GUICtrlRead($playlist)) $dbclick2 = StringTrimRight($dbclick1, 1) $dbclick3 = StringSplit($dbclick2, "|") If $dbclick3[0] <> 1 Then $sound = _SoundOpen($dbclick3[4]) _SoundPlay($sound) GUICtrlSetState($Play, $GUI_DISABLE) GUICtrlSetState($Pause, $GUI_ENABLE) GUICtrlSetState($Stop, $GUI_ENABLE) SB("Playing") Else SB("Error !") EndIf EndFunc ;==>DoubleClickFunc Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $playlist And $code = -3 Then $DoubleClicked = True Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Best Regards, L|M|TER Link to comment Share on other sites More sharing options...
Aassdd Posted March 23, 2008 Author Share Posted March 23, 2008 (edited) Thanks a lot. I'll put credits for sure. I "stole" 1-2 things from your media player and you helped me a lot. Why there's a GUICtrlRead in another? (GUICtrlRead(GUICtrlRead($PlayList))) Edited March 23, 2008 by Aassdd Link to comment Share on other sites More sharing options...
LIMITER Posted March 23, 2008 Share Posted March 23, 2008 I'm glad that i could help you ! The GuiCtrlRead is in another one because the first get's the index of the selected item and the other one get's the txt of that item ... Link to comment Share on other sites More sharing options...
Aassdd Posted March 23, 2008 Author Share Posted March 23, 2008 Thanks again! Link to comment Share on other sites More sharing options...
LIMITER Posted March 23, 2008 Share Posted March 23, 2008 With pleasure ! Link to comment Share on other sites More sharing options...
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