Player API
KalturaPlayers
A map of player instances by player ids
Type: Object<string, KalturaPlayer>
KPPlaylistOptions
Type: Object
Properties
autoContinue
boolean? Determine whether to continue to the next item automatically.loop
boolean? Determine whether to play the playlist in a loop. When is true the playlist will played automatically even autoContinue is false.
KPPlaylistCountdownOptions
Type: Object
Properties
timeToShow
number? Shows when the countdown is scheduled to appear (by default, this is towards the end).duration
number? Shows for how long the countdown will appear.showing
boolean? Determines whether to show the countdown.
KPPlaylistConfigObject
Type: Object
Properties
options
KPPlaylistOptions The playlist options.countdown
KPPlaylistCountdownOptions The playlist countdown configuration.items
Array<PlaylistItem> The playlist items.
KPPlaylistObject
Type: Object
Properties
id
string The playlist ID.metadata
ProviderPlaylistMetadataObject The playlist metadata.options
KPPlaylistOptions The playlist options.countdown
KPPlaylistCountdownOptions The playlist countdown configuration.items
Array<PlaylistItem> The playlist items.
KPPlaylistItemConfigObject
Type: Object
Properties
countdown
KPPlaylistCountdownOptions? Countdown options
BaseRemotePlayer
Extends FakeEventTarget
Basic remote player.
Implements the Kaltura Player playback, ads, tracks,vr and cast APIs.
Remote players should extend this class and implement the needed API.
Parameters
name
string Remote player name.config
Object Cast configuration.remoteControl
RemoteControl Remote control.
loadMedia
Loads a media to the receiver application.
Parameters
mediaInfo
Object The entry media info.
Returns Promise<void> Promise to indicate load succeed or failed.
setMedia
Sets a media to the remote player..
Parameters
mediaConfig
Object Media configuration to set.
Returns void
getMediaInfo
Gets the media Info.
Returns Object? The media info.
configure
Configure the remote player
Parameters
config
Object Configuration to set. (optional, default{}
)
Returns void
ready
The remote player readiness.
Returns Promise<any> Promise which resolved when the remote player is ready.
load
Load the remote player.
Returns void
play
Play/resume the remote player.
Returns void
pause
Pause the remote player.
Returns void
reset
Reset the remote player.
Returns void
destroy
Destroy the remote player.
Returns void
isLive
Examples
BaseRemotePlayer.prototype.isLive() // false
Returns boolean Whether the current playback is a live playback.
isDvr
Examples
BaseRemotePlayer.prototype.isDvr() // false
Returns boolean Whether the current live playback has DVR window. In case of non-live playback will return false.
seekToLiveEdge
Seeks to the live edge.
Returns void
getStartTimeOfDvrWindow
Examples
BaseRemotePlayer.prototype.getStartTimeOfDvrWindow() // 0
Returns number The start time of the DVR window.
getTracks
Parameters
type
string? Track type.
Examples
BaseRemotePlayer.prototype.getTracks() // []
Returns Array<Track> The remote player tracks.
getActiveTracks
Examples
BaseRemotePlayer.prototype.getTracks() // {audio: undefined, video: undefined, text: undefined}
Returns Object The remote player active tracks.
selectTrack
Select a certain track to be active.
Parameters
track
Track The track to activate.
Returns void
hideTextTrack
Hides the active text track.
Returns void
enableAdaptiveBitrate
Enables automatic adaptive bitrate switching.
Returns void
isAdaptiveBitrateEnabled
Examples
BaseRemotePlayer.prototype.isAdaptiveBitrateEnabled() // true
Returns boolean Whether adaptive bitrate is enabled.
setTextDisplaySettings
Sets the text display settings.
Parameters
settings
Object Text settings.
Returns void
startCasting
Start casting.
Returns Promise<any> A promise to indicate session is starting, or failed
stopCasting
Stops the current cast session.
Returns void
isCasting
Examples
BaseRemotePlayer.prototype.isCasting() // true
Returns boolean Whether casting is currently active.
isCastAvailable
Examples
BaseRemotePlayer.prototype.isCastAvailable() // true
Returns boolean Whether casting is available.
getCastSession
Gets the current remote session.
Examples
BaseRemotePlayer.prototype.getCastSession() // new RemoteSession('', '')
Returns RemoteSession The remote session.
isVr
Examples
BaseRemotePlayer.prototype.isVr() // false
Returns boolean Whether the current media is of VR type (360 content).
toggleVrStereoMode
Toggles VR mode on the current content.
Returns void
isInVrStereoMode
Examples
BaseRemotePlayer.prototype.isInVrStereoMode() // false
Returns boolean Whether the current content displayed in VR mode.
ads
The remote player ads controller.
Type: Object?
Examples
BaseRemotePlayer.prototype.ads // null
Returns Object?
textStyle
Setter.
Parameters
style
TextStyle The text style to set.
Returns void
textStyle
Getter.
Examples
BaseRemotePlayer.prototype.textStyle // new TextStyle()
Returns TextStyle The current text style.
buffered
Gets the first buffered range of the remote player.
Examples
BaseRemotePlayer.prototype.buffered // []
Returns Array<any> First buffered range in seconds.
currentTime
Setter.
Parameters
to
number The number to set in seconds.
Returns void
currentTime
Getter.
Examples
BaseRemotePlayer.prototype.currentTime // 0
Returns number The current time in seconds.
duration
Examples
BaseRemotePlayer.prototype.duration // 0
Returns number The duration in seconds.
volume
Setter.
Parameters
vol
number The volume to set in the range of 0-1.
Returns void
volume
Getter.
Examples
BaseRemotePlayer.prototype.volume // 1
Returns number The current volume in the range of 0-1.
paused
Examples
BaseRemotePlayer.prototype.paused // false
Returns boolean Whether the cast player is in paused state.
ended
Examples
BaseRemotePlayer.prototype.ended // false
Returns boolean Whether the cast player is in ended state.
seeking
Examples
BaseRemotePlayer.prototype.seeking // false
Returns boolean Whether the cast player is in seeking state.
muted
Setter.
Parameters
mute
boolean The mute value to set.
Returns void
muted
Getter.
Examples
BaseRemotePlayer.prototype.muted // false
Returns boolean The muted state.
Examples
BaseRemotePlayer.prototype.src // ''
Returns string The current playing source url.
poster
Examples
BaseRemotePlayer.prototype.poster // ''
Returns string The current poster url.
playbackRate
Setter.
Parameters
rate
number The playback rate to set.
Returns void
playbackRate
Examples
BaseRemotePlayer.prototype.playbackRate // 1
Returns string The current playback rate.
engineType
Examples
BaseRemotePlayer.prototype.engineType // ''
Returns string The active engine type.
streamType
Examples
BaseRemotePlayer.prototype.streamType // ''
Returns string The active stream type.
type
Examples
BaseRemotePlayer.prototype.type // BaseRemotePlayer.Type
Returns string The remote player type.
config
Returns KPOptionsObject The runtime remote player config.
defaultConfig
Default configuration of the remote player.
Type: Object
Examples
BaseRemotePlayer.defaultConfig // {}
Type
Remote player type.
Type: string
Examples
BaseRemotePlayer.Type // 'BaseRemotePlayer'
isSupported
Examples
BaseRemotePlayer.isSupported() // true
Returns boolean Whether the remote player is supported in the current environment.
CastEventType
Type: Object
Examples
// Events lifecycle
1. CAST_AVAILABLE
2. CAST_SESSION_STARTING
3. CAST_SESSION_STARTED || CAST_SESSION_START_FAILED -> X
4. CAST_SESSION_ENDING
5. CAST_SESSION_ENDED
// How to use
player.addEventListener(KalturaPlayer.cast.CastEventType.CAST_SESSION_STARTED, e => {
console.log(e.session);
};
PlayerSnapshot
Parameters
player
KalturaPlayer The Kaltura player.
textStyle
Type: TextStyle
advertising
Type: Object
config
Type: Object
RemoteControl
Parameters
player
KalturaPlayer The Kaltura player.
getPlayerSnapshot
Gets the player snapshot.
Type: Function
Returns PlayerSnapshot player snapshot.
getUIWrapper
Gets the UI wrapper.
Type: Function
Returns UIWrapper The UI wrapper.
onRemoteDeviceDisconnected
On remote device disconnected handler.
Type: Function
Parameters
payload
RemoteDisconnectedPayload disconnected payload.
Returns void
onRemoteDeviceConnected
On remote device connected handler.
Type: Function
Parameters
payload
RemoteConnectedPayload connected payload.
Returns void
onRemoteDeviceAvailable
On remote device available handler.
Type: Function
Parameters
payload
RemoteAvailablePayload available payload.
Returns void
onRemoteDeviceConnecting
On remote device connecting handler.
Type: Function
Returns void
onRemoteDeviceDisconnecting
On remote device disconnecting handler.
Type: Function
Returns void
onRemoteDeviceConnectFailed
On remote device connect failed handler.
Type: Function
Returns void
RemotePayload
Parameters
player
BaseRemotePlayer The active remote player.
player
The active remote player.
Type: BaseRemotePlayer
Returns BaseRemotePlayer
RemoteConnectedPayload
Extends RemotePayload
Parameters
player
BaseRemotePlayer The active remote player.session
RemoteSession The remote session.ui
RemotePlayerUI? Optional remote player UI preset.
ui
Remote player UI preset.
Type: RemotePlayerUI?
Returns RemotePlayerUI?
session
Remote session.
Type: RemoteSession
Returns RemoteSession?
RemoteDisconnectedPayload
Extends RemotePayload
Parameters
player
BaseRemotePlayer The active remote player.snapshot
PlayerSnapshot The remote player snapshot.
snapshot
Remote player snapshot.
Type: PlayerSnapshot
Returns PlayerSnapshot
RemoteAvailablePayload
Extends RemotePayload
Parameters
player
BaseRemotePlayer The active remote player.available
boolean Remote player availability.
available
Remote player availability.
Type: boolean
Returns boolean
RemotePlayerUI
playbackUI
Playback UI of the remote player.
Parameters
props
Object UI creation parameters.
Returns React$Element<any> Component.
idleUI
Idle UI of the remote player.
Parameters
props
Object UI creation parameters.
Returns React$Element<any> Component.
adsUI
Idle UI of the remote player.
Parameters
props
Object UI creation parameters.
Returns React$Element<any> Component.
liveUI
Live UI of the remote player.
Parameters
props
Object UI creation parameters.
Returns React$Element<any> Component.
errorUI
Error UI of the remote player.
Parameters
props
Object UI creation parameters.
Returns React$Element<any> Component.
uis
UI presets.
Type: Array<UIPreset>
Returns Array<UIPreset>
IRemotePlayer
textStyle
Type: TextStyle
muted
Type: boolean
playbackRate
Type: number
volume
Type: number
currentTime
Type: number
buffered
Type: number
duration
Type: number
paused
Type: boolean
ended
Type: boolean
seeking
Type: boolean
src
Type: string
poster
Type: string
engineType
Type: string
streamType
Type: string
type
Type: string
ads
Type: Object
config
Type: KPOptionsObject
addEventListener
Parameters
removeEventListener
Parameters
dispatchEvent
Parameters
event
FakeEvent
loadMedia
Parameters
mediaInfo
Object
setMedia
Parameters
mediaConfig
Object
getMediaInfo
Returns Object
configure
Parameters
config
Object
ready
Returns Promise<any>
load
play
pause
reset
destroy
isLive
Returns boolean
isDvr
Returns boolean
seekToLiveEdge
getStartTimeOfDvrWindow
Returns number
getTracks
Parameters
type
string?
Returns Array<Track>
getActiveTracks
Returns Object
selectTrack
Parameters
track
Track
hideTextTrack
enableAdaptiveBitrate
isAdaptiveBitrateEnabled
Returns boolean
setTextDisplaySettings
Parameters
settings
Object
startCasting
stopCasting
isCasting
Returns boolean
isCastAvailable
Returns boolean
getCastSession
Returns RemoteSession
isVr
Returns boolean
toggleVrStereoMode
isInVrStereoMode
Returns boolean
Type
Type: string
isSupported
Returns boolean
RemoteSession
Parameters
id
string Session ID.friendlyName
string Receiver friendly name.resuming
boolean? Whether the session is resuming.
deviceFriendlyName
Receiver friendly name.
Type: string
Returns string
id
Session ID.
Type: string
Returns string
resuming
Whether the session is resuming.
Type: boolean?
Returns boolean?
PlaylistEventType
Type: Object
Examples
// Events lifecycle
1. PLAYLIST_LOADED
2. PLAYLIST_ITEM_CHANGED (multiple)
3. PLAYLIST_ENDED
// How to use
player.addEventListener(KalturaPlayer.playlist.PlaylistEventType.PLAYLIST_LOADED, e => {
console.log(e.payload.playlist.metadata.name);
};
PlaylistItem
Parameters
sources
ProviderMediaConfigSourcesObject? The item sourcesconfig
KPPlaylistItemConfigObject? The item config
updateSources
Update the playlist item sources
Parameters
sourcesObject
ProviderMediaConfigSourcesObject The sources
Returns void
sources
Playlist item sources
Type: ProviderMediaConfigSourcesObject?
Returns ProviderMediaConfigSourcesObject?
config
Playlist item config
Type: KPPlaylistItemConfigObject?
Returns KPPlaylistItemConfigObject?
isPlayable
Returns boolean = Whether the playlist item has sources to play
PlaylistManager
Parameters
player
KalturaPlayer The player instanceoptions
KPOptionsObject The player config object
configure
Config the playlist
Parameters
config
KPPlaylistObject? The playlist configentryList
ProviderEntryListObject? Entry list
Returns void
load
Load a playlist
Parameters
playlistData
KPPlaylistObject The playlist dataplaylistConfig
KPPlaylistConfigObject? The playlist configentryList
ProviderEntryListObject? Entry list
Returns void
reset
Reset the playlist
Returns void
playNext
Play the next item
Returns void
playPrev
Play the previous item
Returns void
playItem
Play a specific item
Parameters
index
number The index of the item to play
Returns void
items
Playlist items
Type: Array<PlaylistItem>
Returns Array<PlaylistItem>
next
Next item
Type: PlaylistItem?
Returns PlaylistItem?
prev
Previous item
Type: PlaylistItem?
Returns PlaylistItem?
id
Playlist id
Type: string
Returns string
metadata
Playlist metadata
Type: ProviderPlaylistMetadataObject
Returns ProviderPlaylistMetadataObject
poster
Playlist poster
Type: string?
Returns string?
countdown
Playlist countdown
Type: KPPlaylistCountdownOptions
Returns KPPlaylistCountdownOptions
options
Playlist options
Type: KPPlaylistOptions
Returns KPPlaylistOptions
loadPlaylist
Loads a playlist by id.
Parameters
playlistInfo
ProviderPlaylistInfoObject The playlist info.playlistConfig
KPPlaylistConfigObject? The playlist config.
Examples
kalturaPlayer.loadPlaylist({playlistId: '123456'}, {options: {autoContinue: false}});
Returns Promise<ProviderPlaylistObject> The playlist data from the provider.
loadPlaylistByEntryList
Loads a playlist by entry list.
Parameters
entryList
ProviderEntryListObject The playlist info.playlistConfig
KPPlaylistConfigObject? The playlist config.
Examples
kalturaPlayer.loadPlaylistByEntryList({entries: [{entryId: '01234'}, {entryId: '56789'}]}, {options: {autoContinue: false}});
Returns Promise<ProviderPlaylistObject> The playlist data from the provider.
configure
Config the player.
Parameters
config
Object The player config. (optional, default{}
)
Examples
kalturaPlayer.configure({playback: {autoplay: true}});
Returns void
playlist
The playlist controller.
Type: PlaylistManager
Examples
KalturaPlayer.playlist.playNext();
Returns PlaylistManager
getPlayers
get all instantiated players
Returns KalturaPlayers map of player ids and their respective instantiated player
getPlayer
get a player instance by id
Parameters
id
string the player ID
Returns **(KalturaPlayer | null)** the player if found by the supplied ID or null if key doesn’t exist |