Team Spartan Cookies & Milk Forums
sounds.playURL() - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: sounds.playURL() (/thread-2254.html)



sounds.playURL() - theamazing - 11-04-2017

Hi,
Yesterday, тѕсм.The17thDoctor, Blackhawk and I tried using the
sound.playURL()
function, but we couldn't find out how. The documentation doesn't help that much about it as well. Could someone explain how it works?


RE: sounds.playURL() - jean730 - 11-04-2017

I tried it, but even with the instructions on the gmod wiki here, it doesnt work.
(I registered the PLAY_URL_SOUNDS)
I also put a print function in the callback but it didnt print in the chat.


RE: sounds.playURL() - Kosmos - 11-04-2017

Code:
sound.playURL(url, "", function(channel, errCode, errMsg))
Which is basically what the documentation tells you, it's the same as playFile, and I haven't had it fail on me so far.
Do note, that GMod waits quite some time before it considers a request timed out or failed (depending on what happened) so if the handler does not get called you most likely gave it the wrong URL in the first place.
It would indeed be very helpful of you if you could provide more details on how you used the function than simply
Code:
sound.playURL()



RE: sounds.playURL() - jean730 - 11-04-2017

Code:
if CLIENT then permissions.register("PLAY_URL_SOUNDS") sounds.playURL("http://jean.langmatt.com/stargate.mp3", "3d", function(music, a, b) _G.print(a) _G.print(b) if music:isValid() then music:play() end end) end



RE: sounds.playURL() - Person8880 - 11-04-2017

Make sure you've granted the chip the right to play sounds from the internet (the shield icon at the top right of the editor). It's not enabled by default.


RE: sounds.playURL() - jean730 - 11-04-2017

ok thanks


RE: sounds.playURL() - Red The Blue Color - 11-04-2017

(11-04-2017, 03:45 PM)jean730 Wrote:
Code:
if CLIENT then permissions.register("PLAY_URL_SOUNDS") sounds.playURL("http://jean.langmatt.com/stargate.mp3", "3d", function(music, a, b) _G.print(a) _G.print(b) if music:isValid() then music:play() end end) end

Incase you are still doing that, you don't need to run music:player() the sound will start playing once its ready. i also recommend using
permissions.canPerformAction(permissions.PLAY_URL_SOUNDS)
before even attempting to play any sounds