Jump to content

playsound


TuRisMo

Recommended Posts

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

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 by Guest
Link to comment

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

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 by Guest
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...