spotify-audio
Audio component that plays Spotify tracks, episodes, playlists, and shows through the Spotify embed
Audio component that plays Spotify content through the Spotify embed: tracks, episodes, albums, playlists, shows, and artists. Podcast episodes play in full for signed-out listeners; music plays as a preview until the listener logs in to Spotify.
Load a source
src takes an open.spotify.com URL for any embeddable entity, including the localized (/intl-de/) and already-embedded (/embed/) forms, or a spotify:<type>:<id> URI. A t parameter sets the start position in seconds.
<SpotifyAudio src="https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5" controls /><spotify-audio src="https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5" controls></spotify-audio>Controls
Spotify’s own chrome is the only UI the embed offers, so controls decides whether the element is visible at all. With controls, it shows Spotify’s player. Without it, the element hides itself and plays as an invisible transport: a hidden iframe still loads and plays, so a player skin’s buttons drive playback while the embed takes no room on the page.
Behavior
The Spotify embed exposes less than a native <audio> element:
- No volume and no mute: the embed takes neither command and reports neither value, so a player skin shows no volume controls at all.
- No playback rate and no text tracks.
loopreplays the entity from the top when it ends; without it, the embed continues into whatever Spotify queues next.
Examples
Basic Usage
import { SpotifyAudio } from '@videojs/react/media/spotify-audio';
export default function BasicUsage() {
return (
<div className="spotify-audio">
<SpotifyAudio src="https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5" controls />
</div>
);
}
.spotify-audio {
width: 100%;
height: 152px;
}
<spotify-audio
class="spotify-audio"
src="https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5"
controls
></spotify-audio>
.spotify-audio {
width: 100%;
height: 152px;
}
import '@videojs/html/media/spotify-audio';
API Reference
Attributes
These attributes configure the embedded media adapter:
| Attribute | Type | Default | Details |
|---|---|---|---|
autoplay | boolean | — | |
controls | boolean | — | |
loop | boolean | — | |
playsinline | boolean | — | |
poster | string | — | |
preload | MediaPreloadType | — | |
src | string | — |
Properties
| Property | Type | Default | Details |
|---|---|---|---|
autoplay | boolean | — | |
buffered | TimeRangeLike | — | |
| |||
controls | boolean | — | |
currentSrc | string | — | |
| |||
currentTime | number | — | |
duration | number | — | |
| |||
ended | boolean | — | |
| |||
engine | SpotifyControllerApi | null | — | |
| |||
error | MediaError | null | — | |
| |||
loop | boolean | — | |
paused | boolean | — | |
| |||
playsInline | boolean | — | |
poster | string | — | |
preload | MediaPreloadType | — | |
readyState | number | — | |
| |||
seekable | TimeRangeLike | — | |
| |||
seeking | boolean | — | |
| |||
source | SpotifySource | null | — | |
| |||
src | string | — | |
textTracks | TextTrackListLike | — | |
| |||
Engine options
source.engine.spotify
Pass Spotify embed options under source.engine.spotify, spelled exactly as Spotify spells them, plus anything Spotify adds next. Media Sources covers how engine options fit into a structured source.
<SpotifyAudio
source={{
src: 'https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5',
engine: { spotify: { t: 90, theme: 0 } },
}}
/>const audio = document.querySelector('spotify-audio');
audio.source = {
src: 'https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5',
engine: { spotify: { t: 90, theme: 0 } },
};| Option | Type | Details |
|---|---|---|
preferVideo | boolean | |
| ||
referrerPolicy | ReferrerPolicy | |
| ||
t | number | |
| ||
theme | 0 | |
| ||
Methods
Supports these media methods: loadpauseplay
Events
Implements these standard media events through the embedded player: durationchangeemptiedendederrorloadedmetadataloadstartpauseplayplayingseekedseekingtimeupdatewaiting
Also emits these Video.js-specific events:
| Event | Description |
|---|---|
loadcomplete | |
sourcechange | Fired when `source` changes, either directly or by resolving a new `src`. Read `source` for the new value. |