Youtube APIs not working with sound.PlayURL()?


The link has to be to a direct mp3, wav, or ogg file, not to a download page.

Is there a way to convert this to a direct link?

Actually download the video’s mp3 and put it on Google Drive or something. I think Google Drive has direct links if you get the right URL.

[editline]1st November 2017[/editline]

it doesn’t seem to actually. damn it

Is the information on this thread incorrect then?

I guess it must actually work. I think what code_gs actually meant is instead of the URL you are going to:
You need to use the actual direct URL on that page:

This is my Google Drive link that I was trying to get to end with .mp3 by the way:
That might work as well (maybe)…

EDIT: sorry, I’m really dumb. I didn’t see that was what you were already doing.

That’s what I am using, I’m getting the ‘link’ value from the JSON in the first link which contains the second link

Guess you can’t play from the API link directly so you should download the file with http.Fetch and play it with sound.PlayFile. Here’s a working example:

http.Fetch(“”, function(body)
local json = util.JSONToTable(body)

http.Fetch(, function(data)
	file.Write("stuff.dat", data)

	sound.PlayFile("data/stuff.dat", "noblock", function(station, ...)
		if (IsValid(station)) then

			timer.Simple(station:GetLength(), function()
			print("Failed to play", ...)


[editline]1st November 2017[/editline]

Although this API seems really finicky so sometimes this code will not work.

Was hoping I wouldn’t have to do that. Thanks though.

You could always just use an invisible Awesomium panel embedding the video.

You can’t change the volume of it though, right?

Afaik youtube videos don’t have anything to change/force the volume (because of obvious reasons).
Last time I looked this up was about 3 months ago.

[editline]2nd November 2017[/editline]

Why obvious reasons? Garry’s Mod doesn’t let you change the system volume for obvious reasons, but YouTube’s volume can’t do any harm.
The worst it can do is play at 100% volume, which shouldn’t surprise you if your system volume is already way up.

Using Awesomium can be quite unstable, especially on YouTube.

For my radio addon I used the / API for like 2 years by now but it seemed getting more and more unreliable even with using a clientside cache.

I noticed that videos that haven’t been converted recently by manually clicking the “Download” button will not give a working download URL.

In the past I got more and more reports of these “yt not work, fix it” in the comments to that point that I have gave up supporting YouTube in this addon.
I probably will remove it soon, also because making people read (in-game) helps and instruction next to the error display for the required manual step is not possible.
By the way I was recently told that the API is indeed somehow broken. Atleast it is for some users of this addon, including me.

So I think you do yourself favor by avoiding that YouTube thing unless you are willing to set up you own converting server or something.

My bad I forgot I was mentioning just basic iframes with no javascript.

Obvious reasons being setting the volume to a song to ear rape people with. My headset is constantly on 28% volume but 100% youtube volume gets loud as fuck if it’s not from like 2013.