Skip to content

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. Only mediaId is 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),
  },
});
EventWhen it fires
readyThe player has loaded and is ready to be controlled.
playPlayback started.
pausePlayback paused.
timeupdatePlayback moved forward – the handler receives the current second.
loadedmetadataMedia details, like the duration, became available.
endedPlayback reached the end.
volumechangeThe volume changed, or the sound was muted or unmuted.
errorSomething 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'),
  },
});