Skip to main content

Player Methods Reference

Track Management

isAutoBitrate()

Returns a value representing if auto bitrate switching is enabled or not. (For IOS this is always true)

Returns: boolean

player.isAutoBitrate();

setAutoBitrate(autoBitrate)

Sets the automatic bitrate switching property (Ignored on IOS, ABR is always enabled).

ValueDescription
autoBitrate booleanEnable ABR

Returns: void

player.setAutoBitrate(true);

getTracks()

Returns the loaded tracks in the player

Returns
{
video: Array<{
width: number,
height: number,
bitrate: number,
language: string,
active: boolean
}>,
audio: Array<{
bitrate: number,
language: string,
channels: number,
active: boolean
}>,
caption: Array<{
language: string,
label: string,
type: string,
active: boolean
}>
}

useTrack(type, track)

Switches to the track of your choice that comes from getTracks() method.

ValueDescription
type string"video" | "audio" | "caption"
track ObjectTrack that you want to switch to.
const x = player.getTracks();
player.useTrack("video", x.video[0]);

Configuration Management

getConfig()

Returns the configuration object provided by the user.

Returns: UnifiedConfig

player.getConfig();

setConfig(config)

Configures the LuraPlayer based on the given configuration object.

ValueDescription
config lura.configurations.UnifiedConfigIf media stays the same, updates metadata, if media changes destroys and reinitializes

Returns: Promise<void>

player.setConfig({
content: {
media: [
{url: "https://www.example.com/example.mpd", "application/xml+dash"}
]
}
});

destroy()

Destroys the player, disconnects all events, cleanup resources

Returns: void

player.destroy();

reload()

Destroys the player, and reloads the current config.

Returns: void

player.reload();

Playback Management Methods

play()

Requesting the video to play.

Returns: void

player.play();

pause()

Requesting the video to pause.

Returns: void

player.pause();

isAutoplay()

Returns the autoplay setting of the player

Returns: boolean

player.isAutoplay();

setAutoplay(autoplay)

Sets the autoplay setting of the player to the given value

ValueDescription
autoplay booleanAutoplay value you want to set

Returns: void

player.setAutoplay(true);

isContentEnded()

Returns a boolean indicating whether the media content has ended

Returns: boolean

player.isContentEnded();

isLoading()

Indicates if player is loading

Returns: boolean

player.isLoading();

isPaused()

Returns a boolean indicating whether the player is paused

Returns: boolean

player.isPaused();

getVideoType()

Returns the type of video ("VOD" or "LIVE")

Returns: lura.enums.LuraVideoType

player.getVideoType();

getMediaFormat()

Returns the format of the media (e.g. "mp4", "m3u8-variant")

Returns: lura.enums.LuraMediaFormat

player.getMediaFormat();

getStreamUrl()

Returns the stream url of the playing media.

Returns: string

player.getStreamUrl();

getPlaybackSpeed()

Returns the playback speed

Returns: number

player.getPlaybackSpeed();

setPlaybackSpeed(number)

Sets the playback speed between 0.1 and 16

Returns: void

player.setPlaybackSpeed(number);

getVolume()

Returns the current volume of the player

Returns: number

player.getVolume();

setVolume(volume)

Sets the volume of the player to the given value

ValueDescription
volume numberA value between 0 and 1

Returns: void

player.setVolume(number);

isMuted()

Returns a boolean indicating whether the player is muted

Returns: boolean

player.isMuted();

setMuted(muted)

Sets the muted setting of the player to the given value

ValueDescription
muted booleanWhether you want the video to be muted or not

Returns: void

player.setMuted(boolean);

requestFullscreen()

Requests fullscreen mode for the player

Returns: void

player.requestFullscreen();

requestPictureInPicture()

Requests Picture-in-Picture mode for

Returns: void

player.requestPictureInPicture();

getDuration()

Returns video duration

Returns: number

player.getDuration();

seek(time)

Seeks to a specific time (seconds)

ValueDescription
time numberTime in seconds that you want to seek to.

Returns: void

player.seek(10);

catchLive()

Seeks to the end of the seekable range in live videos.

Returns: void

player.catchLive();

getLivePosition()

Returns the live position in live streams

Returns: number

player.getLivePosition();

getBufferedDuration()

Returns buffered duration

Returns: number

player.getBufferedDuration();

getBufferedStart()

Returns buffered start

Returns: number

player.getBufferedStart();

getBufferedEnd()

Returns buffered end

Returns: number

player.getBufferedEnd();

getNativeBufferedStart()

Returns stitched buffered start

Returns: number

player.getNativeBufferedStart();

getNativeBufferedEnd()

Returns stitched buffered end

Returns: number

player.getNativeBufferedEnd();

getCurrentTime()

Returns current playback time

Returns: number

player.getCurrentTime();

getPoster()

Returns the video poster URL

Returns: string

player.getPoster();

setPoster(url)

Sets the video poster URL

ValueDescription
url stringPoster URL value you want to set

Returns: void

player.setPoster("https://picsum.photos/640/360");

requestTrickPlayImage(time, desiredWidth)

Requests the trick play image for a given time with image data closest to the desiredWidth. LuraPlayer will download and load the bif image closest to the desiredWidth and will return a base64 encoded JPG buffer (async) through TRICK_PLAY_DATA_EVENT after bif image is loaded.

Returns: void

player.requestTrickPlayImage(10, 200);

getTrickPlayInformation()

Returns the trick play information loaded into the player.

Returns: Array<{width: number, height: number}>

player.getTrickPlayInformation();

Ad Management Methods

getInterstitials()

Returns the interstitials

Returns: {"breaks": Array<lura.interfaces.AdBreak>}

player.getAdBreakPositions();

skipAd()

Skips the current ad

Returns: void

player.skipAd();

timeWithoutAds(number)

Returns the given time with ads before that time removed (seconds)

Returns: number

player.timeWithoutAds(number);

timeWithAds(number)

Returns the given time with ad times added before that time (seconds)

Returns: number

player.timeWithAds(number);

Annotation Management Methods

getAnnotations()

Returns the annotations

Returns: {"breaks": Array<lura.interfaces.AdBreak>}

player.getAdBreakPositions();

Event Methods

setListener(callback)

Sets the event listener of the Lura Player.

ValueDescription
callback (e: lura.events.UnifiedEvent) => voidThe callback function when the event is dispatched

Returns: void

function handler(e) {
switch (e.type) {
case "CONFIGURED":
console.log("configured");
break;
default:
break;
}
}
player.setListener(handler);