TuRisMo Posted December 13, 2012 Share Posted December 13, 2012 I want to play the music URL from the gridlist item, but when I click on the button it does not work local music = guiGridListGetItemText ( gridlist1, guiGridListGetSelectedItem ( gridlist1 ), column1 ) function playTheSound ( ) sound = playSound (music) setSoundVolume (sound, 1.0) outputChatBox ( " Started Playing " ..music ) end addEventHandler ( "onClientGUIClick", button2, playTheSound, false ) function stopTheSound ( ) stopSound(sound) outputChatBox ( music.. "Stoped" ) end addEventHandler ( "onClientGUIClick", button3, stopTheSound, false ) Link to comment
Jaysds1 Posted December 13, 2012 Share Posted December 13, 2012 (edited) try this: local sound = nil --define the var global function playTheSound ( ) local music = guiGridListGetItemText ( gridlist1, guiGridListGetSelectedItem ( gridlist1 ), column1 ) --column1 isn't defined sound = playSound (music) setSoundVolume (sound, 1.0) outputChatBox ( " Started Playing " ..music ) end addEventHandler ( "onClientGUIClick", button2, playTheSound, false ) function stopTheSound ( ) stopSound(sound) outputChatBox ( music.. "Stopped" ) end addEventHandler ( "onClientGUIClick", button3, stopTheSound, false ) and if this doesn't work, then I would need to see the full script Edited December 13, 2012 by Guest Link to comment
myonlake Posted December 13, 2012 Share Posted December 13, 2012 Ugh... you need to put the guiGridListGetItem function in the "playTheSound" function you have. Otherwise it would load the gridlist select before you have clicked anything and should already show up an error in /debugscript 3. So just put it in there and maybe it should work, as far as I can see. Link to comment
TuRisMo Posted December 13, 2012 Author Share Posted December 13, 2012 myonlake solution worked, thanks for your help both Link to comment
TuRisMo Posted December 13, 2012 Author Share Posted December 13, 2012 (edited) I want help in something else, how to check if the sound is over? I mean, I am going to make a checkbox for "Enabling Replay" when the song is over. so it would be like that function replay() if ( --the song is over) then if ( guiCheckBoxGetSelected(checkbox1) ) then startSound( sound ) end end end Edited December 13, 2012 by Guest Link to comment
manve1 Posted December 13, 2012 Share Posted December 13, 2012 this is an example ((not sure if works)) : if ( not sound ) then local sound = playSound(music) end Link to comment
myonlake Posted December 14, 2012 Share Posted December 14, 2012 this is an example ((not sure if works)) : if ( not sound ) then local sound = playSound(music) end Nope. Use isElement function. isElement Link to comment
myonlake Posted December 14, 2012 Share Posted December 14, 2012 You're welcome again. Link to comment
TuRisMo Posted December 14, 2012 Author Share Posted December 14, 2012 I couldn't find out how to use the ifElement correctly with audios Link to comment
Castillo Posted December 14, 2012 Share Posted December 14, 2012 You do it like with any other element. isElement ( sound ) Link to comment
myonlake Posted December 15, 2012 Share Posted December 15, 2012 Make sure the sound isn't a local variable, it has to be a global. So instead of.. local sound = ... .. do.. sound = ... Link to comment
Anderl Posted December 15, 2012 Share Posted December 15, 2012 Are you sure the gridlist text is the file path? 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