Skip to content

Jetstream player API methods

JetstreamPlayer class available methods

The following methods are available in this version of the library:

  • play()
  • pause()
  • mute()
  • unmute()
  • seekTo()
  • playNext()
  • playPrev()
  • isMuted()
  • isPaused()
  • getVideoCurrentTime()
  • getDuration()
  • dispose()

This list is not exhaustive. New methods can be added to the library as needed.

To use these methods, import the JetstreamPlayer class and call them as described in the previous section.

js
import { JetstreamPlayer } from '@hopecloud/jetstream-player';

let player;

onMounted(() => {
  player = new JetstreamPlayer('#iframe1', {
    mediaId: 'jsv:xxxxxxxxxx',
  });
});

player.play();

play() and pause()

The play or pause method can be called for a video as well as for a playlist. We are able to interact with our videos or playlists programmatically in the same way as pressing pause or play within the iframe itself.

Pay attention ☝️⬇️

When the web page with our embedded windows has just loaded and there has been no user action (click, play), and the video has sound enabled, the programmatic play() function will not execute!

The play() function will not work due to Autoplay policy in Chrome. The same behavior occurs with services YouTube, Facebook, etc.

Modern browsers don't provide a way to bypass this setting. Therefore, the first time, a user action is necessary (click inside the iframe window). After this action, all methods will work normally.

If the video or playlist has sound disabled (muted), then all methods work normally.

mute()

The mute() function sets the media volume to silent.

unmute()

Unmutes the volume.

isMuted()

Returns true if the player volume is muted, false if not.

seekTo(seconds: number)

Seeks the video to the specified time in seconds.

playNext() and playPrev()

The playNext or playPrev method can be called only for a playlist. Calling these methods for a simple video will do nothing. We can interact with a playlist programmatically in the same way as pressing playNext or playPrev within the playlist itself.

isPaused(): Promise<boolean>

Returns a Promise that resolves with a boolean indicating whether the video is paused.

getVideoCurrentTime(): Promise<number>

Returns a Promise that resolves with the current playback time of the video in seconds.

getDuration(): Promise<number>

Returns a Promise that resolves with the total duration of the video in seconds.

dispose()

Disposes of the player instance and removes event listeners.