[Release] [JS] Radio

radio
javascript

#1

FiveM Radio

This resource allows you to integrate your own radios in place of the original radios.
It’s fully written in JavaScript and uses resource metadata for its configuration.

Erratum: this resource uses a not-meant-to-be-exposed internal API surface. Don’t blame FiveM if this resource doesn’t work anymore after an update.

Features

  • Radio wheel
  • Audio file
  • Audio stream
  • No dependency
  • Easy configuration

Showcase

Video showing Los Santos Rock Radio replaced by a WebRadio and Non-Stop-Pop FM replaced by a song:
Showcase

Known bugs and limitations

  • No MPEG, MP3 or AAC support as CEF only supports open formats

Downloads

Archive: https://github.com/Hellslicer/fivem-radio/archive/master.zip
Source: https://github.com/Hellslicer/fivem-radio

Configuration

For each custom radio, add this line in _resource.lua:

supersede_radio "[ORIGINAL_RADIO_NAME]" { url = "[RADIO URL]", volume = 0.5, name = "[NEW RADIO NAME]" }

You can find the list of radio names in data.js and a full example in __resource.lua.

Tips

Stream a modified hud.ytd (gtav_radio_stations_texture_512) file to replace radio logos.

Changelog

1.0.0

  • Properly handle audio streams
  • Add an option to replace in-game radio name
  • Mute background radio radio when a custom one is playing

0.1.0

  • Radio wheel
  • Audio file and stream

Speaker on the server
#2

Moved to #development:releases


#3

is it possible to stream a radio for example a stream??? or is that not possible? would be nice if you could stream actual radio sources via broadcasting your own radio for your server


#4

Releases like this make me happy to have my own web server to put music for this on :stuck_out_tongue:


#5

Yes, it’s possible and this is the main feature of this resource.
Check the __resource.lua file, it contains two example streams. You can replace these links by your own Webradio.


#6

haha holy shit, just yesterday i was saying to my other dev that it be sweet to have this, and now we have it, great release.


#7

Thanks a lot for this awesome release, just tried it on my dev server using Linux FX server and it’s amazing;
But when using stream URLs like your example it works for about 1min30s then stops. Seems like a caching issue or so, if I restart the radio resource while server is up then music is back instantly. I have tried a lot of different stream url, same behavior everytime. Do you have any idea ?


#8

Don’t know why it doesn’t work for me, just plays the default gta station rip.


#9

anybody have URLS of live radio of los angeles or where I can fine them


#10

what else does it support then .ogg links ?


#11

It’s a known problem that can be solved. I’ll fix it myself if nobody does it via PR (contribution).


#12

Here is the list of supported audio codec formats:

  • FLAC
  • Opus
  • PCM 8-bit unsigned integer
  • PCM 16-bit signed integer little endian
  • PCM 32-bit float little endian
  • Vorbis

#13

Thanks a lot, I tried to fix it myself but unfortunately was not able to.
Thank you for your prompt response and support.
And btw its not 1:30min but exactly 2:00min and also surprising is the fact that I had users in production that get no cuts…
For me even on a winodws or linux fivem server; same result.


#14

@Hellslicer Is it possible to block all radios in the game? for authorized only ours?


#15

One quick option that you have and which will not be the best one would be to replace all readios by yours. Sorry for this dirty method :wink:
Otherwise you override all radios with empty ones.
(told you real dirty method :wink: )


#16

I get an error : Couldn’t load resource radio ( https://i.imgur.com/P1srcQa.png) .How do I solve it?


#17

Unfortunately I have no other solutions than those proposed by @tobias1


#18

Hey Hellslicer, if you have an idea regarding the bug after 2min musics stops, can you please let me know how to solve it ?


#19

Maybe add the radio resource to your resources folder ? :stuck_out_tongue:


#20

Yep: track the currentTime and reset the audio source when it’s stuck.
Kinda dirty tho

Edit: A proper solution would be to use the onerror event, but for some reason it’s never trigerred.