Skip to main content

Player Methods

Track Management

isAutoBitrate()

Returns a value representing if auto bitrate switching is enabled or not.

note

For IOS & ROKU it always returns true.

Returns: boolean

player?.isAutoBitrate();

setAutoBitrate(autoBitrate)

Sets the automatic bitrate switching property.

note

Ignored on IOS & ROKU, ABR is always enabled.

ValueDescription
autoBitrate booleanEnable ABR

Returns: void

player?.setAutoBitrate(autoBitrate);

getTracks()

Returns the loaded tracks in the player

Returns: lura.unified.Tracks

player?.getTracks();

useTrack(type, track)

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

ValueDescription
type lura.unified.TrackTypesType of the track
track lura.unified.VideoTrack | lura.unified.AudioTrack | lura.unified.CaptionTrackTrack that you want to switch to.
const x = player?.getTracks();
player?.useTrack(type, x.video[0]);

isDisplayingCaptions()

Returns a value representing if caption is displaying or not.

Returns: boolean

player?.isDisplayingCaptions();

displayCaptions(display)

Sets the displaying value of captions.

ValueDescription
display booleanDisplay captions

Returns: void

player?.displayCaptions(display);

Configuration Management

getConfig()

Returns the configuration object provided by the user.

Returns: lura.unified.Configuration

player?.getConfig();

setConfig(config)

Configures the LuraPlayer based on the given configuration object.

ValueDescription
config lura.unified.ConfigurationInitial configuration of the lura player.

Returns: void

player?.setConfig(config);

updateConfig(config)

Partially updates the configuration. Updatable fields are marked as updatable in the Configuration section. (e.g. Title or plugin metadata)

ValueDescription
config lura.unified.ConfigurationUpdatable parts of the configuration.

Returns: void

player?.updateConfig(config);

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 the 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.unified.VideoType

player?.getVideoType();

getMediaFormat()

Returns the format of the media (e.g. "DASH", "HLS")

Returns: lura.unified.MediaFormat

player?.getMediaFormat();

getPlaybackSpeed()

Returns the playback speed

Returns: number

player?.getPlaybackSpeed();

setPlaybackSpeed(speed)

Sets the playback speed between 0.1 and 16

ValueDescription
speed numberPlayback speed value you want to set

Returns: void

player?.setPlaybackSpeed(speed);

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(volume);

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(muted);

getScreenState()

Returns the screen state, whether it should be picture in picture, fullscreen or windowed.

Returns: lura.unified.ScreenState

player?.getScreenState();

setScreenState(state)

Sets the screen state, whether it should be picture in picture, fullscreen or windowed.

ValueDescription
state lura.unified.ScreenStateCurrent screen state

Returns: void

player?.setScreenState(state);

getDuration()

Returns video duration in seconds

Returns: number

player?.getDuration();

seek(time)

Seeks to a specific time (seconds). In live stream, seeking is only possible when there is availability window in the live stream. Availability windows will be present if the live stream has DVR enabled from the encoder.

ValueDescription
time numberTime in seconds that you want to seek to. For live streams, unix timestamp in seconds.

Returns: void

player?.seek(time);

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();

getCurrentTime()

Returns current playback time

Returns: number

player?.getCurrentTime();

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.

ValueDescription
time numberPresentation time of the trick play image that you want to request.
desiredWidth numberDesired width of the trick play image.

Returns: void

player?.requestTrickPlayImage(time, desiredWidth);

getTrickPlayInformation()

Returns the trick play information available in the player.

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

player?.getTrickPlayInformation();

getAvailabilityWindows()

Returns the available seekable ranges in a live stream.

Returns: lura.unified.AvailabilityWindow[]

player?.getAvailabilityWindows();

Playlist Methods

getPlaylistItems()

Returns the items from the playlist configuration.

Returns: Array<lura.unified.Configuration>

player?.getPlaylistItems();

getPlaylistItem(index)

Returns the item at the given index or null if not exists.

ValueDescription
index numberIndex of the playlist item that you want to get.

Returns: lura.unified.Configuration

player?.getPlaylistItem(index);

updatePlaylistItem(item, index)

Updates the playlist item at the given index.

ValueDescription
item lura.unified.ConfigurationNew playlist item that you have updated.
index numberIndex of the playlist item that you want to update.

Returns: void

player?.updatePlaylistItem(item, index);

removePlaylistItem(index)

Removes the playlist item at the given index.

ValueDescription
index numberIndex of the playlist item that you want to remove.

Returns: void

player?.removePlaylistItem(index);

addPlaylistItem(item, index)

Adds a playlist item to the given index. If index is not provided, playlist item will be added as the last item.

ValueDescription
item lura.unified.ConfigurationNew playlist item that you want to insert.
index number | nullIndex of the playlist item that you want to add.

Returns: void

player?.addPlaylistItem(item, index);

getCurrentPlaylistItemIndex()

Returns the index of the currently playing playlist item.

Returns: number

player?.getCurrentPlaylistItemIndex();

setPlaylistRepeat(repeat)

Sets the value for whether the playlist should run in repeat mode or not.

ValueDescription
repeat booleanWhether the playlist should run in a loop or not.

Returns: void

player?.setPlaylistRepeat(repeat);

loadPlaylistItem(index)

Loads the playlist item configuration with the given index if exists.

ValueDescription
index numberIndex of the playlist item that you want to play.

Returns: void

player?.loadPlaylistItem(index);

loadNextPlaylistItem()

Loads the next item in the playlist. Will play the first item if this method is called at the last playlist item.

Returns: void

player?.loadNextPlaylistItem();

loadPreviousPlaylistItem()

Loads the previous item in the playlist. Will play the last item if this method is called at the first playlist item.

Returns: void

player?.loadPreviousPlaylistItem();

setPlaylistAutoSwitchMechanism(autoSwitch)

Enable/disable the automatic switching mechanism in between playlist items.

ValueDescription
autoSwitch booleanWhether auto switching mechanism should be enabled or not.

Returns: void

player?.setPlaylistAutoSwitchMechanism(autoSwitch);

abortPlaylistAutoSwitch()

Aborts the automatic switching mechanism for current switching. Auto switch will be turned on again for the next video if the auto switch mechanism is enabled.

Returns: void

player?.abortPlaylistAutoSwitch();

updatePlayerView(newPlayerView)

Updating LuraPlayerView to new instance of it.

ValueDescription
newPlayerView LuraPlayerViewNew instance of LuraPlayerView.

Returns: void

player?.updatePlayerView(newPlayerView = newPlayerView)

Ad Management Methods

getInterstitials()

Returns the interstitials

Returns: Array<lura.unified.AdBreak>

player?.getInterstitials();

skipAd()

Skips the current ad

Returns: void

player?.skipAd();

Event Methods

addListener(listener)

Sets the event listener of the Lura Player. Returns an id for removing the listener.

ValueDescription
listener (e: lura.unified.UnifiedEvent<k: lura.unified.UnifiedEventName> => voidThe listener function when the event is dispatched

Returns: string

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

removeListener(listener)

Removes the event listener from the Lura Player.

ValueDescription
listener stringThe id of the listener function from addListener

Returns: void

player?.removeListener(listener);

Cast Management Methods

requestCasting(castTarget)

Requests casting to the selected target if available.

ValueDescription
castTarget lura.unified.CastTargetsThe list of cast targets that can be used.

Returns: void

player?.requestCasting(castTarget);

isCasting(castTarget)

Returns a value representing whether LuraPlayer is casting to a cast target or not.

ValueDescription
castTarget lura.unified.CastTargetsThe list of cast targets that can be used.

Returns: boolean

player?.isCasting(castTarget);

exitCasting(castTarget)

Ends or tries to end the casting of the cast target.

ValueDescription
castTarget lura.unified.CastTargetsThe list of cast targets that can be used.

Returns: void

player?.exitCasting(castTarget);

getCastingAvailability()

Returns the availability of the casting targets.

Returns: {[key in lura.unified.CastTargets]?: boolean}

player?.getCastingAvailability();

Miscellaneous

setCustomData(key, value)

Sends custom data through the CUSTOM_DATA_CHANGED event.

ValueDescription
key stringKey of the custom data
value anyValue of the custom data.

Returns: void

player?.setCustomData(key, value);

getCustomData(key)

Gets the custom data for the given key.

ValueDescription
key stringKey of the custom data.

Returns: Any

player?.getCustomData(key);

getTimeUpdateData()

Returns the TIME_UPDATED event payload for the current time.

player?.getTimeUpdateData();

Old Methods

requestFullscreen()

info

Deprecated, please use setScreenState

Requests fullscreen mode for the player

Returns: void

player?.requestFullscreen();

exitFullscreen()

info

Deprecated, please use setScreenState

Requests exiting the fullscreen mode for the player

Returns: void

player?.exitFullscreen();

isFullscreen()

info

Deprecated, please use getScreenState

Returns whether the player is in fullscreen mode or not.

Returns: boolean

player?.isFullscreen();

requestPictureInPicture()

info

Deprecated, please use setScreenState

Requests Picture-in-Picture mode

Returns: void

player?.requestPictureInPicture();

exitPictureInPicture()

info

Deprecated, please use setScreenState

Exits Picture-in-Picture mode

Returns: void

player?.exitPictureInPicture();

isPictureInPicture()

info

Deprecated, please use getScreenState

Returns whether the player is in picture in picture mode or not.

Returns: boolean

player?.isPictureInPicture();