Muchuchu Posted May 11, 2008 Share Posted May 11, 2008 (edited) Trying to make a simple music player just for learning experience. Can\'t seem to get it right. It won\'t do the while statement if I press play even though it seems like i coded it correctly, but I\'m obviously doing something wrong. Here\'s the script. expandcollapse popup#include <Sound.au3> #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate(\"Form1\", 255, 81, 439, 140) global $song = GUICtrlCreateInput(\"\", 80, 8, 153, 21) $Label1 = GUICtrlCreateLabel(\"Song Name\", 8, 11, 60, 17) $Play = GUICtrlCreateButton(\"Play\", 48, 40, 65, 33, 0) $Stop = GUICtrlCreateButton(\"Stop\", 128, 40, 65, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd while 1 $nMsg = GUIGetMsg() if $nmsg = $play then start() endif wend func start() Msgbox(1,\"starting\",\"Starting\") _SoundOpen (\"C:\\Users\\Tim\\Documents\\\" & $song & \".mp3\") sleep(\"2000\") _soundplay(\"C:\\Users\\Tim\\Documents\\\" & $song & \".mp3\") msgbox(1,\"Finished\",\"done\") endfunc Edited May 11, 2008 by Muchuchu Link to comment Share on other sites More sharing options...
Generator Posted May 11, 2008 Share Posted May 11, 2008 (edited) Trying to make a simple music player just for learning experience. Can\'t seem to get it right. It won\'t do the while statement if I press play even though it seems like i coded it correctly, but I\'m obviously doing something wrong. Here\'s the script. #include <Sound.au3> #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate(\"Form1\", 255, 81, 439, 140) global $song = GUICtrlCreateInput(\"\", 80, 8, 153, 21) $Label1 = GUICtrlCreateLabel(\"Song Name\", 8, 11, 60, 17) $Play = GUICtrlCreateButton(\"Play\", 48, 40, 65, 33, 0) $Stop = GUICtrlCreateButton(\"Stop\", 128, 40, 65, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $play start() EndSwitch WEnd func start() Msgbox(1,\"starting\",\"Starting\") _SoundOpen (\"C:\\Users\\Tim\\Documents\\\" & $song & \".mp3\") sleep(\"2000\") _soundplay(\"C:\\Users\\Tim\\Documents\\\" & $song & \".mp3\") msgbox(1,\"Finished\",\"done\") endfuncYour problem was the first while loop was never finished so it cannot detect whether you pressed play or not. Edited May 11, 2008 by Generator 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