Jump to content

[HELP] Music player GUI, Stack Overflow


NotAvailable

Recommended Posts

Posted

Hi,

Im working on a music player GUI.

But when i press the ON button, It says in debug:

ERROR: audio/audio_c.lua:14: Stack Overflow

Here is my code(client):

addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
  
        window = guiCreateWindow(15,306,121,48,"Audio Options",false) 
guiWindowSetSizable(window,false) 
        on = guiCreateButton(9,24,40,15,"on",false,window) 
        addEventHandler ( "onClientGUIClick", on, playSound, false ) 
        off = guiCreateButton(64,25,40,14,"off",false,window) 
        addEventHandler ( "onClientGUIClick", off, stopSound, false ) 
    end 
) 
  
function playSound () 
local sound = playSound("cripsnbloods.mp3", false) 
setSoundVolume(sound, 0.5) 
end 
  
function stopSound () 
 setSoundPaused(sound, true) 
end 
  
  

I dont know whats the problem,

Regards,

Jesseunit

Posted

your mp3 file is broken (even if winamp plays it correctly anyway)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

send me full script with mp3 sound.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

oh i see..

you are overwriting default playSound function with your own - you called it playSound.

so if you are using playSound in playSound - you got an endless loop.

rename your functions

also i think you should use stopSound, not setSoundPaused - as you are not unpausing it - which means you are creating new sound everytime you click play.

also you should block play if sound is playing (use global variable like: isPlaying or isElement(sound) should be good too)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
oh i see..

you are overwriting default playSound function with your own - you called it playSound.

so if you are using playSound in playSound - you got an endless loop.

rename your functions

also i think you should use stopSound, not setSoundPaused - as you are not unpausing it - which means you are creating new sound everytime you click play.

also you should block play if sound is playing (use global variable like: isPlaying or isElement(sound) should be good too)

Ok, thanks! :D

Posted

post your code again

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
post your code again
addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        window = guiCreateWindow(15,306,121,48,"Audio Options",false) 
        guiWindowSetSizable(window,false) 
        on = guiCreateButton(9,24,40,15,"on",false,window) 
        addEventHandler ( "onClientGUIClick", on, startSound, false ) 
        off = guiCreateButton(64,25,40,14,"off",false,window) 
        addEventHandler ( "onClientGUIClick", off, lol, false ) 
    end 
    ) 
     
function startSound () 
local sound = playSound("armysound.mp3", false) 
setSoundVolume(sound, 1.0) 
end 
  
  
function lol () 
if isElement(sound) == playing then 
  setSoundVolume(sound, 0.0) 
end 
end 

Posted

i said doing this like that

  
function startSound () 
local sound = playSound("armysound.mp3", false) 
setSoundVolume(sound, 1.0) 
end 
  
  
function lol () 
if isElement(sound) == playing then 
  setSoundVolume(sound, 0.0) 
end 
end 
  

will make new sound created every play - you are only muting sound but its actually playing. in some extreme conditions it will be slowing down pc and may cause crash too.

also i said use global variable OR isElement, you mixed it without thinking what are you really doing..

  
if isElement(sound) == playing then 
  

FIX:

  
function startSound() 
  if not isElement(sound) then -- if our sound is not existing we can create one 
    sound = playSound("armysound.mp3", false) -- can't be local, because there will be no way to stop it (okay, there is one way but.. whatever) 
    setSoundVolume(sound, 1.0) -- i think this is default volume.. do we really need it? 
  end 
end 
  
  
function lol() 
  if isElement(sound) then -- if our sound is existing - we will stop it 
    stopSound(sound) 
  end 
end 
  

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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...