Add a Listen Live button to your website

A listen live button is a button or link on your website that starts your station's HTTPS stream, or opens its player, with one tap. You need three things: the HTTPS listen link from your radio control panel, a site that is itself on HTTPS, and a button that only starts audio when the visitor presses it. This guide gives you the code, where to place it, what changes on phones, and the checks to run before you announce it on air.

Steps
7
Reviewed
Runs on
Radio
Written by
Get Stream Hosting

By the Get Stream Hosting team

Every step was checked against the software's official documentation by independent reviewers before publishing. Last reviewed .

Pre-flight check

Three ways to build it

Pick the version that matches how much control you want over the page. All three point at the same stream; they differ in what happens when the visitor taps.

BuildWhat the tap doesGood forWatch out for
A plain linkOpens your station page or pop-out player in a new tabAny site builder, menus, email footersAudio lives in another tab; visitors may not notice it started
A button wired to an audio elementPlays the stream right where the visitor isYour own theme, a sticky header barStops when the visitor follows a link to another page
The embeddable playerPlays in the station's own player inside your pageHome page, a dedicated listen pageNeeds a space in the layout that fits it

Many stations combine them: the embedded player on the home page, and a small Listen live link in the header of every other page that opens the pop-out player.

What to have ready

  • The HTTPS listen link. Each station on our SSL radio streaming plans has one in the control panel, alongside an http version kept for legacy players. Your website takes the HTTPS version.
  • A site served over HTTPS. A secure page will not load an insecure stream it cannot upgrade. If your site still runs on plain http, move it to HTTPS first; our web hosting with a control panel issues and renews certificates for you.
  • An address people can say on air. A short domain name for the site makes "tap Listen live at" easy to read out between songs.
  • Your station name and artwork, for the button label and the phone lock screen.

Never put a stream address that uses a raw IP address into an https page. Browsers upgrade http audio requests to https automatically, but they block the request outright when the host is an IP address instead of a domain name.

The button, in code

Paste this where the button should appear and replace the placeholder address with your HTTPS listen link. It uses only standard browser features: an audio element with no visible controls, and a real button element that starts and stops it.

<button type="button" id="listen">Listen live</button>
<audio id="radio" preload="none"
  src="https://your-station.example/stream"></audio>
<script>
const btn = document.getElementById('listen');
const radio = document.getElementById('radio');
btn.addEventListener('click', () => {
  if (radio.paused) {
    btn.textContent = 'Connecting';
    radio.play().catch((err) => {
      if (err.name === 'AbortError') return;
      btn.textContent = 'Listen live';
      window.open(radio.src, '_blank', 'noopener');
    });
  } else {
    radio.pause();
    radio.load();
    btn.textContent = 'Listen live';
  }
});
radio.addEventListener('playing', () => { btn.textContent = 'Stop'; });
radio.addEventListener('waiting', () => { btn.textContent = 'Buffering'; });
</script>

What each part does:

  • preload="none" keeps the browser from opening the stream until the tap, so a visitor who never listens uses no data and does not show up as a listener.
  • play() returns a promise. If the browser refuses to start the audio, the catch opens the stream in a new tab instead of leaving a dead button; it ignores the AbortError raised when the visitor taps Stop before sound starts.
  • On stop, pause() followed by load() drops the connection. The next tap fetches the stream fresh, so the listener rejoins the live broadcast rather than an old buffer.
  • The playing and waiting events keep the label honest: it says Stop only once sound is actually coming out.

To confirm it worked, tap the button on your own site, wait for audio, and check that the label reads Stop. Then open your station's statistics: the current listener count should go up by one.

Where it goes on the page

  • In the header of every page, to the right of the menu. Listeners arrive on any page from search, social posts and show notes, not only the home page.
  • At the top of the home page, large, next to what is on now. The embedded player does this job if you use it.
  • On each show page, next to the show times, so a fan of one programme can start it straight away.
  • In a sticky bar on phones, pinned to the bottom of the screen, where a thumb reaches it.

Size matters on touch screens. The accessibility guidelines ask for pointer targets of at least 24 by 24 CSS pixels, and recommend 44 by 44 for the higher level. Give the button a visible label that says what it does; Listen live beats a bare play icon for someone using a screen reader.

Use a button element for a control that plays audio on the page, and an a element for one that goes somewhere, such as the pop-out player. Screen reader users expect a link to take them to a new place and a button to act on the current one.

How it behaves on phones

  • Nothing plays without a tap. Browsers generally block audible playback that a script starts before the visitor has clicked or tapped anything on the page. Never set the stream to autoplay; make the button the start.
  • Leaving the page ends the audio. On a normal multi-page site, following any link unloads the audio element. Send phone visitors to the pop-out player in its own tab if you want listening to survive browsing.
  • The lock screen can show your station. The browser's Media Session feature lets the page hand the phone a title, artist and artwork, and react to the play and pause keys on headphones and the lock screen. Set it after playback has started.
  • Data counts. The station's embeddable player offers a mobile data saver, and a Platinum station carries 3 streams, letting phones pick a lower bitrate.

Check it on a real phone, on mobile data rather than office Wi-Fi: tap, lock the screen, and confirm the audio keeps going and your station name shows on the lock screen.

Checks before you announce it

  1. Open your site in Chrome, Safari, Firefox and Edge. Tap the button in each; audio should start within a few seconds.
  2. Keep the developer tools console open while you tap. There should be no mixed content warning and no failed request for the stream.
  3. Tap stop, wait a minute, tap again. You should hear what is on air now, not what was playing a minute ago.
  4. Try it with your encoder disconnected. On the free plan the button should fail cleanly; on paid plans AutoDJ or your fallback list should keep sound on the link.
  5. Check your live listener count rises when you tap and falls when you stop.

When it goes wrong

SymptomLikely causeWhat to do
Button does nothing, console shows a blocked requestThe stream address uses http with an IP hostSwap in the HTTPS listen link with its domain name
Works on desktop, silent on the phonePlayback was started by a script, not by the tapCall play() directly inside the click handler
Spins for ever, then stopsThe station is off air or the link is mistypedOpen the listen link alone in a tab; if it fails there, check the encoder
Audio stops when visitors browseThe page with the audio element was unloadedLink to the pop-out player in a new tab instead
Old audio after resumingThe element resumed from its bufferCall load() after pause(), as in the example

If the listen link itself will not play in a bare browser tab, the problem is upstream of your website. Check the encoder's connection settings in your control panel, then open a ticket or a chat: live chat runs 24/7.

Questions people ask

Can the stream start by itself when someone opens my site?

Not reliably, and it should not try. Browsers generally block audio that starts before the visitor has clicked, tapped or pressed a key on the page, and unexpected sound drives people away. Let the Listen live button start it.

Should the button open a new tab or play on the page?

Play on the page when the visitor is likely to stay on it, such as a home page with the player. Open a new tab for header links on a site with many pages, so the audio keeps going while they browse. Opening a new tab with target set to _blank is safe in current browsers; add rel="noopener" for older ones.

Does a Listen live button work on a free station?

Yes. The free radio plan includes the secure HTTPS listen link and the embeddable player, so the button works the same way. Paid plans add things the button can lead to, such as rewind of the live stream on Premium and Platinum.

Will it work on a website builder that does not allow scripts?

Use the plain link version. Link the button or menu item to your station page or pop-out player and make it open in a separate tab. No code is needed on your side.

How do I know people are using it?

Watch the live listener figure in your station statistics while you tap it yourself. On Premium and Platinum the statistics also break listeners down by referrer, which shows how many arrive from your website.

Can listeners cast from the button?

A bare audio element plays on the device. For Chromecast and AirPlay, point the button at the station's embeddable player; it has both, on all plans.

Radio

Put your stream on air

Your station's secure stream address and its player are ready for a Listen live button from day one, free plan included.