JustinReno Posted January 5, 2008 Posted January 5, 2008 (edited) I'm making a music player that uses _SoundPlay($Sound, 0) so the user can pause/stop/resume after that. But I have a couple lines of code that when a sound has ended, it goes to the next. But when I put that piece of code in the While/WEnd loop, I think it keeps restarting. Here is a reproducer: #Include <Sound.au3> $Sound = @WindowsDir&"\Media\Notify.wav" $SoundOpen = _SoundOpen($Sound) _SoundPlay($SoundOpen, 0) While 1 If _SoundPos($Sound) = _SoundLength($Sound) Then _SoundClose($Sound) _SoundOpen($Sound); I will replace the sound later... _SoundPlay($Sound, 0) ;I think this is the problem, but how would I solve it? EndIf WEnd Edited January 5, 2008 by JustinReno
PsaltyDS Posted January 5, 2008 Posted January 5, 2008 You need to pay attention to where the string file name ($sound) should be used, and where the string ID of the current open sound ($SoundOpen) should be used: #Include <Sound.au3> HotKeySet("{ESC}", "_Quit") $Sound = @WindowsDir&"\Media\Notify.wav" $SoundOpen = _SoundOpen($Sound) _SoundPlay($SoundOpen, 0) While 1 If _SoundPos($SoundOpen) = _SoundLength($SoundOpen) Then _SoundClose($SoundOpen) $SoundOpen = _SoundOpen($Sound); I will replace the sound later... _SoundPlay($Sound, 0) ;I think this is the problem, but how would I solve it? EndIf Sleep(20) WEnd Func _Quit() _SoundClose($SoundOpen) Exit EndFunc Crack open the Sound.au3 UDF and look more closely at the functions you are calling. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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