Music is the feature people ask for most on a loading screen, and it's also the one that breaks most often. Players join and hear nothing. Or they hear a wall of distorted noise blasting at full volume, which is somehow worse. Either way the first impression is gone. Good news is that GMod's embedded browser is friendlier to autoplay than a normal browser, so getting this right is easier than you'd think.
Why autoplay works in GMod but not in Chrome
Modern browsers block audio autoplay until the user interacts with the page. GMod's loading screen runs inside CEF (Chromium Embedded Framework) configured by the game itself, and it allows autoplay without any user gesture. That matters, because the player physically cannot click anything during loading. The loading screen gets no mouse input at all.
Formats and encoding that work
- MP3 — the safe default. GMod's CEF decodes it every time. 192 kbps is plenty. Nobody's picking out the difference through a game loading screen.
- OGG Vorbis — also supported and slightly smaller, popular in older loading screen templates.
- WAV — works, but the files are huge. A 3-minute WAV can run past 30 MB, and every player downloads that before they hear a note. Avoid it.
- Streaming services — YouTube and Spotify embeds do NOT work. They need iframes, DRM and interaction that GMod's old Chromium can't give them. Host a plain audio file instead.
A minimal working example
<audio id="music" src="https://cdn.example.com/music.mp3" loop></audio>
<script>
var music = document.getElementById("music");
music.volume = 0.35; // NEVER start at 1.0
var playing = music.play();
if (playing && playing.catch) {
// In a normal browser (preview), autoplay may be blocked: fall back to click.
playing.catch(function () {
document.addEventListener("click", function () { music.play(); }, { once: true });
});
}
</script>A few details matter here. volume = 0.35 is deliberate. Starting at full volume is what players complain about more than anything else with loading screen music. The loop attribute is there because long downloads outlast most songs. And the .catch() fallback keeps the same page working when you preview it in a desktop browser, where autoplay is blocked.
Give players a mute button (the one exception)
Loading screens can't receive clicks, with one practical caveat. Some player setups do register the mouse, and a visible mute control also tells people the music is intentional rather than a bug. Here's the convention that works. Render a small speaker icon, wire it to toggle music.muted, and make sure the screen looks right whether or not anyone ever clicks it. Don't gate anything important behind that button.
Common mistakes
- Hosting audio over plain HTTP on an HTTPS page — mixed content gets blocked and the player hears nothing. Serve the file over the same protocol as the page. This is a common issue on shared servers and it can be hard to spot, because the preview works fine.
- Huge files — the browser has to buffer enough audio before playback starts. A 20 MB track on a slow connection is silence for the first minute. Compress to MP3 and keep it under about 5 MB.
- No loop, no playlist — a 90-second song on a 4-minute first join leaves you with dead silence right when the player is already getting impatient.
- Copyright-flagged tracks — your loading screen is public. Stick to licensed or royalty-free music, especially if you promote the server on YouTube.
The zero-code way
Every Lumescreen theme has music built in. Upload any MP3, OGG or WAV in the dashboard. It gets compressed to a streaming-friendly MP3, hosted on a CDN, wired for CEF autoplay at a sensible default volume, with a mute control already attached. No HTML, no hosting, none of the format headaches. Set sv_loadingurl once (here's how) and you're done.