Jetstrem player API methods
JetstreamPlayer
class available methods
Next 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.
In order to use these methods, it is enough to import the JetstreamPlayer
class and call them as described in the previous section.
import { JetstreamPlayer } from '@hopecloud/jetstream-player';
let player;
onMounted(() => {
player = new JetstreamPlayer('#iframe1');
});
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 is just loaded and there has been no user action (click, play) and video has the sound settings on
, 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 an opportunity to avoid this setting. Therefore, for the first time, an action on the user side is necessary (click in the iframe window). After this action, all methods will work clearly.
If the video or playlist has sound settings off (muted)
, then all methods work in normal mode.
mute()
Mute function set media volume to silent.
unmute()
Cancel volume mute.
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 are able to interact with 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.