Embed

Embed the DataMind FM player

From a 40-pixel pill in your footer to a full-screen stage: one player, live audio, now playing and lock-screen controls. Free, on any page.

Which one should I use

You wantUseSize
A quiet player in a footer or a docs sidebarMicro240 × 44
A slim bar in a sidebar or next to an articleMini bar320 × 64
A player inside a blog postCard400 × 160
The full show on a landing page, a TV or a phonePulse or Video16:9, 1:1, 9:16
What is on air, without audioNow-playing badge320 × 64
Music on every page of your site, one line of codeFloating (embed.js)340 × 76
A README, where iframes and scripts do not runText linktext

Build your embed

Variant
Options
Iframe
Script tag

Options

Every variant is the same player at https://embed.datamind.fm/ with URL parameters. With the script tag, use the same names as data- attributes.

ParameterValuesDefaultWhat it does
layoutstage, card, mini, micro, badge, floatstageThe variant. compact=1 still works and means card.
modepulse, video, audiopulseStage only. Pulse is the DataMind FM mark moving with the music, Video is the generative live video, Audio only has no visuals. Listeners can switch, and their choice is remembered. visual is an old name for pulse.
themedark, light, auto, transparentdarkAuto follows the viewer's system setting. Transparent drops the background and follows the viewer too; use it on plain backgrounds.
accentcoral, tealcoralColour of the play button, live dot and progress. The DataMind FM tile stays coral.
radius0 to 40per variantCorner radius in pixels. Round the iframe the same way.
title1, 01Show the track title. With 0 the player shows the station name.
listeners1, 0on for mini, card, stageShow how many people are listening.
muted1offStart muted. Together with autoplay=1, most browsers allow the stream to start on its own.
autoplay1offTry to start on load. Without muted=1, browsers usually block sound until the listener clicks, and the player shows Play. Keep allow="autoplay" on the iframe.

One script tag

embed.js adds one iframe and nothing else: no cookies, no inline styles, no eval. With data-layout="floating" it docks a player bottom right that folds into a round button and remembers that choice. With any other layout it places the player where the script tag is.

<script src="https://embed.datamind.fm/embed.js" data-layout="floating" data-mode="pulse" async></script>
  • Attributes. data-layout, data-mode, data-theme, data-accent, data-radius, data-title, data-listeners, data-autoplay, data-muted; for inline layouts also data-width and data-height; for floating, data-position="left".
  • One global. window.DataMindFM with play(), stop(), command(name, value) and remove().
  • Content Security Policy. If your site sends one, allow the script and the frame:
script-src https://embed.datamind.fm;
frame-src https://embed.datamind.fm;

postMessage API

Your page can control any variant and follow what it plays. Messages are plain objects with a type field. Commands are accepted from any origin and events are posted to any origin, so always check event.origin on your side.

Commands, from your page to the player

  • { type: "dmfm:command", command: "play" }: connect at the live edge. Needs a user gesture on your page.
  • "stop": disconnect the stream. "live": jump back to the live edge after a pause.
  • "mute", "unmute": keep the connection, silence the sound.
  • { command: "setMode", value: "pulse" }: "pulse", "video" or "audio" (stage only). "toggleMode" switches between Audio only and the last visual mode.
  • { command: "setVolume", value: 0.5 }: volume from 0 to 1. iOS always uses the hardware volume.
  • "expand", "collapse": open or fold the floating player.

Events, from the player to your page

  • { type: "dmfm:ready", layout }: sent once when the player has loaded.
  • { type: "dmfm:state", layout, state, nowPlaying }: sent whenever something changes. state holds playing, muted, mode, volume and atLiveEdge (it is null for the badge, which has no audio). nowPlaying is the track the listener hears right now, a few seconds behind the server: title, slug, startedAt and duration, or null while the stream is offline.
  • { type: "dmfm:resize", width, height, collapsed }: floating layout only, used by embed.js to size the frame.

Example

<iframe id="dmfm" src="https://embed.datamind.fm/?layout=mini"
  title="DataMind FM live player" width="320" height="64"
  style="border:0;border-radius:14px;max-width:100%;color-scheme:light" allow="autoplay" loading="lazy"></iframe>

<script>
  const frame = document.getElementById('dmfm');
  const ORIGIN = 'https://embed.datamind.fm';

  function send(command, value) {
    frame.contentWindow.postMessage({ type: 'dmfm:command', command, value }, ORIGIN);
  }

  window.addEventListener('message', (event) => {
    if (event.origin !== ORIGIN || event.source !== frame.contentWindow) return;
    const msg = event.data;
    if (msg?.type === 'dmfm:state') console.log(msg.state.playing, msg.nowPlaying?.title);
  });

  // Browsers only start audio after a user gesture on your page:
  document.querySelector('#listen').addEventListener('click', () => send('play'));
</script>

Good to know

  • Free to use. Embed it on as many pages as you like. Every variant keeps a small "Powered by DataMind FM" link.
  • Light on your page. Micro, mini, card, badge and floating never load the animation code; only Pulse and Video do, and they pause when out of view.
  • Background playback. The player uses a plain audio stream, so listening continues with the screen locked on phones, with the track on the lock screen.
  • Privacy. No cookies. The player counts anonymous events such as Play and Stop with cookieless analytics (Plausible), including the hostname of the page that embeds it. The badge counts nothing.
  • oEmbed. Platforms that support oEmbed discovery can turn a datamind.fm link into the player.