Playlist and chapter navigation for WaveformPlayer. Turn a list of tracks into a player with track switching, artwork and clickable chapters.
npm install @arraypress/waveform-playlist @arraypress/waveform-player<div data-waveform-playlist>
<div data-track data-url="episode.mp3" data-title="Episode 42" data-artist="with Dr. Sarah Chen">
<div data-chapter data-time="0:00">Introduction</div>
<div data-chapter data-time="5:30">Main Topic</div>
</div>
</div>The same markup, as a custom element. Its attributes are the playlist's
data-* options with or without the data- prefix:
<waveform-playlist layout="hero" show-volume continuous>
<div data-track data-url="intro.mp3" data-title="Intro" data-duration="187"></div>
<div data-track data-url="episode.mp3" data-title="Episode 42">
<div data-chapter data-time="0:00">Introduction</div>
<div data-chapter data-time="5:30">Main Topic</div>
</div>
</waveform-playlist>- Changing an attribute or a track rebuilds it, and the current track keeps playing (from the same spot) if it is still in the list. Moving the element keeps playback; removing it destroys the playlist.
el.playlistis theWaveformPlaylist;el.play(),el.pause(),el.next()andel.previous()control it. Events (waveformplayer:*) bubble from the element.- The default import and the CDN script register the tag (and scan for
data-waveform-playlist) unless the page sets<html data-waveform-autoinit="false">. From@arraypress/waveform-playlist/no-autoinit(no auto-init at all), calldefineWaveformPlaylistElement()— optionally with another tag name. - Before it upgrades it is a block reserving
--wp-element-height(90px by default); set that to your playlist's height to avoid any shift.
Full options, chapters and the JavaScript API live in the docs.
MIT © ArrayPress