Appearance
Player Options
You create a player with two things: where it goes and how it behaves.
ts
new JetstreamPlayer(el, options);el– a CSS selector of the element the player appears in, e.g.'#player'.options– everything below. OnlymediaIdis required.
mediaId required
The id of the media to play – a video, an audio, or a whole playlist.
playerId
The player preset to use – presets control how the player looks and behaves, and are configured in Jetstream. Omit it to use the media's default preset.
width and height
The size of the player on your page. Defaults: 480px × 270px.
sticky
Set it to true and the player won't disappear when the visitor scrolls past it – it keeps playing in a small window pinned to the corner of the screen, and returns to its place when the visitor scrolls back.
events
Functions the player calls when something happens:
ts
const player = new JetstreamPlayer('#player', {
mediaId: 'jsv:xxxxxxxxxx',
events: {
ready: () => console.log('ready to be controlled'),
timeupdate: (seconds) => console.log('now at', seconds),
},
});| Event | When it fires |
|---|---|
ready | The player has loaded and is ready to be controlled. |
play | Playback started. |
pause | Playback paused. |
timeupdate | Playback moved forward – the handler receives the current second. |
loadedmetadata | Media details, like the duration, became available. |
ended | Playback reached the end. |
volumechange | The volume changed, or the sound was muted or unmuted. |
error | Something went wrong. |
You can also subscribe after the player is created – see Player Methods.
audioLang and subtitleLang
Preferred audio and subtitle languages, as two-letter codes ('en', 'de'). When the media has a matching track, the player selects it.
region
Set it to 'eu' to serve the player from EU-based hosts.
embedOrigin
For special setups: load the player from a different embed host, such as a staging environment. Most sites never need this.
ts
const player = new JetstreamPlayer('#player', {
mediaId: 'jsv:xxxxxxxxxx',
embedOrigin: 'https://embed-stage.jetstream.studio',
});origin is a deprecated alias of this option – it still works, but new code should use embedOrigin.
A fuller example
ts
const player = new JetstreamPlayer('#player', {
mediaId: 'jsv:xxxxxxxxxx',
playerId: 'jsp:xxxxxxxxx',
width: '640px',
height: '360px',
sticky: true,
audioLang: 'en',
subtitleLang: 'de',
events: {
play: () => console.log('playing'),
pause: () => console.log('paused'),
},
});