xSound for FiveM
Positional audio from URLs and YouTube: car radios, boomboxes, club systems and anything else that has to play sound at a place in the world.
The game's own audio system cannot play a stream from the internet at a coordinate. xSound can: it runs an HTML5 audio element inside a NUI layer and attaches its volume and panning to a world position, which is how every car radio, club sound system and boombox script on FiveM works.
Why servers run it
- Positional playback — volume and stereo image follow a coordinate or an entity.
- Accepts direct URLs and YouTube links, which is what players actually paste.
- Per-listener control, so one player can mute a boombox without muting it for everyone.
- The same NUI audio technique a hosted loading screen uses for background music.
Installing xSound
1. Drop it in and ensure it early
Other scripts call its exports at start.
2. Plan for moderation
Any script that lets players paste a URL will eventually be used to play something you would rather it did not. Whitelist, rate limit, or log every play with the player id.
3. Respect autoplay rules
Browsers block audio before a user gesture. Inside the game's NUI this is usually not a problem, but it is the reason the same trick fails on a website preview.
Working examples
A boombox at a coordinate
exports.xsound:PlayUrlPos('boombox', 'https://example.com/track.mp3', 0.4,
vector3(-1037.2, -2737.5, 20.2))
exports.xsound:Distance('boombox', 30.0)
-- later
exports.xsound:setVolume('boombox', 0.2)
exports.xsound:Destroy('boombox')What goes wrong
Unmoderated URL input is a liability. Log who played what; you will need it.
Sounds are per client. A sound started for one player does not exist for another unless you start it for them too.
Destroy your sounds. An orphaned sound id keeps playing and keeps a NUI audio element alive.
xSound — questions people ask
Can I use xSound for loading screen music?
Runs alongside
The official Cfx.re resource for taking a screenshot of the game and uploading it — the backbone of every in-game camera, report and evidence system.
The shared library half the modern FiveM ecosystem depends on: menus, notifications, progress bars, zones, callbacks and a cache.