Fabioxps Posted December 27, 2014 Share Posted December 27, 2014 stop the music at the end, before destroying? getSoundLength getSoundPosition setSoundPaused setSoundPosition --position 0 not destroy the music and resumes it element playSound ( string soundPath, [ bool looped = false ] ) I do not want to use the agurmento loop to resume music Link to comment
3B00DG4MER Posted December 27, 2014 Share Posted December 27, 2014 playSound("Your Path here", false) in loop do false means don't reply on finnish. Link to comment
Fabioxps Posted December 27, 2014 Author Share Posted December 27, 2014 I want to repeat the sound and stop not to destroy. help? Link to comment
3B00DG4MER Posted December 27, 2014 Share Posted December 27, 2014 I want to repeat the sound and stop not to destroy.help? first you've to define the sound as variable local mySound = playSound("You Path Here", bool loop) for loop do true or false (True means repeat when finnsh, false don't repeat) if you want to stop the sound use stopSound function stopSound(mySound) Link to comment
[M]ister Posted December 28, 2014 Share Posted December 28, 2014 The only way I found for not destroy the element when the music run out, was the following: sound = playSound("...") setSoundPaused(sound,true) function refresh() if getSoundPosition(sound)+1 < getSoundLength(sound) then if not isSoundPaused(sound) then setSoundPaused(sound,false) end else setSoundPaused(sound,true) removeEventHandler("onClientRender",root,refresh) end end -- example of use addCommandHandler("cmd",function(cmd,subcmd) if subcmd == "start" then addEventHandler("onClientRender",root,refresh) elseif subcmd == "restart" then setSoundPosition(sound,0) --addEventHandler("onClientRender",root,refresh) elseif subcmd == "stop" then removeEventHandler("onClientRender",root,refresh) setSoundPaused(sound,true) setSoundPosition(sound,0) end end) If you use in server side you can using setTimer for doing the checking Link to comment
Fabioxps Posted December 28, 2014 Author Share Posted December 28, 2014 The only way I found for not destroy the element when the music run out, was the following: sound = playSound("...") setSoundPaused(sound,true) function refresh() if getSoundPosition(sound)+1 < getSoundLength(sound) then if not isSoundPaused(sound) then setSoundPaused(sound,false) end else setSoundPaused(sound,true) removeEventHandler("onClientRender",root,refresh) end end -- example of use addCommandHandler("cmd",function(cmd,subcmd) if subcmd == "start" then addEventHandler("onClientRender",root,refresh) elseif subcmd == "restart" then setSoundPosition(sound,0) --addEventHandler("onClientRender",root,refresh) elseif subcmd == "stop" then removeEventHandler("onClientRender",root,refresh) setSoundPaused(sound,true) setSoundPosition(sound,0) end end) If you use in server side you can using setTimer for doing the checking I had already made their code this perfect thank you. <3 Link to comment
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