Sources
What url accepts
-- A web link, used as it is
exports.tm_sound:PlayUrl('siren', 'https://example.com/siren.ogg', 0.5)
-- A file of tm_sound (path from the resource root)
exports.tm_sound:PlayUrl('beep', 'sounds/beep.ogg', 0.8)
-- A file of another resource
exports.tm_sound:PlayUrl('alert', 'my_other_resource:sounds/alert.ogg', 1.0)
exports.tm_sound:PlayUrl('alert', '@my_other_resource/sounds/alert.ogg', 1.0)A path without a resource always refers to tm_sound, even when a server script plays it, because the player's game resolves it.
How a file is found
For a file path, the client first tries LoadResourceFile. When the file can be read, it is encoded as a data: link and played directly, so the other resource does not need the file in its files block. The encoded file is cached (up to 16 MB), so a sound that plays often is read once.
When the file cannot be read, the client falls back to https://cfx-nui-<resource>/<path>, which needs the file declared in that resource's files block.
For big or frequently used files, list them in files so they are served directly:
files { 'sounds/**/*.*' }Supported file types are ogg, mp3, wav, webm, aac, flac and m4a.
Web sources
| Source | Links | Notes |
|---|---|---|
| Direct files | .mp3 .m4a .aac .wav .oga .weba, and video containers .mp4 .webm .mov .m4v .ogv | Web Audio, so full EQ, filters and panning. Video containers stream through an html5 element. |
| YouTube | watch, youtu.be, Shorts, live | Embedded player, no EQ. |
| HLS and DASH | .m3u8, .mpd, stream.mux.com | The player library loads the first time one plays. A live stream reports no length and cannot seek. |
| Vimeo | vimeo.com/<id> | Player SDK. |
| Twitch | twitch.tv/<channel>, twitch.tv/videos/<id> | Audio quality. A live channel cannot seek. |
| TikTok | tiktok.com/@user/video/<id> | Full links only. There is no volume level, so distance falloff becomes a mute below a whisper. |
| Wistia | wistia.com/medias/<id>, wi.st/medias/<id> | JavaScript API. |
| Spotify | track, album, playlist and episode links | No volume control: the sound pauses when inaudible and resumes when audible again. Only 30 second previews play unless the browser is logged in. |
Anything else is treated as a direct file. A source that plays in a third party player shares the YouTube limits: no EQ or filters (the acoustic effects become a volume change) and speed only where that player supports it. Looping is done when the end is reported.
YouTube
By default a YouTube link goes to the clients immediately and plays in an embedded player. With Resolve YouTube links on, the server turns the link into a direct audio stream first (through the public Invidious servers in the Invidious instances setting), so the sound plays in the Web Audio graph and keeps its EQ, filters and spatial behavior. If every server fails, the original link is used.
Watch links with a start time (?t=90 or &start=90) start at that time.