NELyon Posted June 16, 2007 Share Posted June 16, 2007 I'm working on a music player. So far, i can get it to load a song, and play a song, and show how far into the song you are. But there is one small problem: My buttons won't return messages when clicked. So if i play a song, the pause button won't work, and the exit button won't work. Can i do this or will i have to stick to another language for the actual playing and stopping? expandcollapse popup#include <GUIConstants.au3> #include <sound.au3> #NoTrayIcon Global $pos, $song #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Kenton-Player: Digital Audio Player", 553, 197, 193, 123) GUISetBkColor(0xA6CAF0) $Input1 = GUICtrlCreateInput("Browse...", 8, 0, 529, 24) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetState(-1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton("Browse for Music", 200, 32, 113, 25, 0) $Button2 = GUICtrlCreateButton("Play", 8, 136, 105, 25, 0) $Button3 = GUICtrlCreateButton("Pause", 144, 136, 113, 25, 0) $Button4 = GUICtrlCreateButton("Stop", 288, 136, 113, 25, 0) $Button5 = GUICtrlCreateButton("Reload", 432, 136, 105, 25, 0) $Label1 = GUICtrlCreateLabel("Kenton-Player - Digital Audio Player", 160, 72, 216, 20) $seek = GUICtrlCreateSlider(10, 300) GUICtrlSetBkColor(-1, 0xA6CAF0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $file = FileOpenDialog("Open Music", "C:\", "Music Files (*.mp3)") $song = _SoundOpen($file, "current") GUICtrlSetData($Input1, $file) Case $Button2 If $song <> "" Then _SoundPlay("current") Do GUICtrlSetData($Label1, _SoundPos("current")) Until $nMsg = $Button4 Else MsgBox(0, "Error", "No song is selected") EndIf Case $Button3 If @Compiled Then $CmdLine = '_SoundPause("current")' Run( @ScriptFullPath & " /AutoIt3ExecuteLine """ & $CmdLine & """", @ScriptDir, 2) Else Run( @AutoItExe & " /AutoIt3ExecuteLine """ & $CmdLine & """", @ScriptDir, 2 ) EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
NELyon Posted June 17, 2007 Author Share Posted June 17, 2007 Can anyone help me? Link to comment Share on other sites More sharing options...
Generator Posted June 17, 2007 Share Posted June 17, 2007 (edited) This should get you going, try to fix it yourself( I am busy making StarCraft map lol). Things to fix. Stop Button I tidied up a bit so easier to see. Since I am not good at using those func, you need to figure out how to set the sound back to 00:00:00, that's almost all i think. Your problem was you were doing a loop but the msg is not being recieved. expandcollapse popup#include <GUIConstants.au3> #include <sound.au3> #NoTrayIcon Global $pos, $song, $inplay #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Kenton-Player: Digital Audio Player", 553, 197, 193, 123) GUISetBkColor(0xA6CAF0) $Input1 = GUICtrlCreateInput("Browse...", 8, 0, 529, 24) GUICtrlSetColor(-1, 0xC0C0C0) GUICtrlSetState(-1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton("Browse for Music", 200, 32, 113, 25, 0) $Button2 = GUICtrlCreateButton("Play", 8, 136, 105, 25, 0) $Button3 = GUICtrlCreateButton("Pause", 144, 136, 113, 25, 0) $Button4 = GUICtrlCreateButton("Stop", 288, 136, 113, 25, 0) $Button5 = GUICtrlCreateButton("Reload", 432, 136, 105, 25, 0) $Label1 = GUICtrlCreateLabel("Kenton-Player - Digital Audio Player", 160, 72, 216, 20) $seek = GUICtrlCreateSlider(10, 300) $inplay = False GUICtrlSetBkColor(-1, 0xA6CAF0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $file = FileOpenDialog("Open Music", "C:\", "Music Files (*.mp3)") $song = _SoundOpen($file, "current") GUICtrlSetData($Input1, $file) Case $Button2 If $song <> "" Then If $inplay = True Then _SoundResume($song) Do $nMsg = GUIGetMsg() GUICtrlSetData($Label1, _SoundPos("current")) Until $nMsg = $Button4 Or $nMsg = $Button3 Or $nMsg = $GUI_EVENT_CLOSE If $nMsg = $Button4 Then _SoundClose($song) _SoundOpen($song) $inplay = Not $inplay ElseIf $nMsg = $Button3 Then _SoundPause($song) $inplay = Not $inplay ElseIf $nMsg = $GUI_EVENT_CLOSE Then Exit EndIf ElseIf $inplay= False Then _SoundPlay("current") Do $nMsg = GUIGetMsg() GUICtrlSetData($Label1, _SoundPos("current")) Until $nMsg = $Button4 Or $nMsg = $Button3 Or $nMsg = $GUI_EVENT_CLOSE If $nMsg = $Button4 Then _SoundClose($song) $song = _SoundOpen($file, "current") ElseIf $nMsg = $Button3 Then _SoundPause($song) $inplay = Not $inplay ElseIf $nMsg = $GUI_EVENT_CLOSE Then Exit EndIf Else MsgBox(0, "Error", "No song is selected") EndIf EndIf Case $Button3 If @Compiled Then $CmdLine = '_SoundPause("current")' Run(@ScriptFullPath & " /AutoIt3ExecuteLine """ & $CmdLine & """", @ScriptDir, 2) Else Run(@AutoItExe & " /AutoIt3ExecuteLine """ & $CmdLine & """", @ScriptDir, 2) EndIf EndSwitch WEnd Edit: The thing to fix is actually the stop button, also use GUICtrlSetState() to disable the play button while the song is being played. Edited June 17, 2007 by Generator Link to comment Share on other sites More sharing options...
2o2 Posted June 17, 2007 Share Posted June 17, 2007 nice!!! Rick rack ree, kick 'em in the knee.Rick rack rass, kick 'em in the other knee! 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