Player SDK (Legacy)
Our JavaScript Player SDK allows you to automatically embed audio versions into their source pages using our player UI or your own UI.
This means that you can build a UI and customize player controls to suit your needs. For example, it is possible to render the player to all users but only make it usable to those with a subscription.
The JavaScript Player and SDK is client-side JavaScript library that is separate from the API. You connect to it differently, and it gives you a different range of options.
Install the JavaScript Player
You can install the JavaScript Player and SDK through NPM:
Or, you can reference an up‐to‐date version on our CDN:
Initialize the JavaScript Player
To initialize the JavaScript Player, use the following:
Or, intialize the JavaScript Player with the SDK, import the package:
Then use the following:
Player events
You can run custom functions based on specific Player events using the on
and off
listener to bind your functions to the events:
appInst.events
supported a next methods
on(type, handler)
: Register an event handler for the given typeoff(type, handler)
: Remove an event handler for the given type
Play
This event fires when playback is initiated.
Event data
duration
number
The total duration of the audio in seconds, rounded to two decimal places, e.g. 28.05
.
---
progress
number
The duration of the audio already played in seconds, rounded to two decimal places, e.g. 28.05
.
Sample event data
Pause
This event fires when audio is paused.
Event data
duration
number
The total duration of the audio in seconds, rounded to two decimal places, e.g. 28.05
.
---
progress
number
The duration of the audio played, when the pause was triggered, in seconds, rounded to two decimal places, e.g. 28.05
.
Sample event data
timeUpdate
This event fires every 25ms during playback and indicates, in seconds, the duration of the audio that has been played, e.g. 28.05
.
Event data
duration
number
The total duration of the audio in seconds, rounded to two decimal places, e.g. 28.05
.
---
progress
number
The duration of the audio played in seconds, rounded to two decimal places, e.g. 28.05
.
Sample event data
playbackRate
This event fires when the playback rate of the audio in the Player changes.
Event data
playbackRate
number
The new playback rate, e.g. 1.5
.
ended
This event fires when the audio completes playback.
Event data
playbackRate
number
The new playback rate, e.g. 1.5
.
Last updated