Player

interface Player : EventEmitter<Event> , RemoteControlApi

Loads, controls and renders audio and video content represented through Sources. A player instance can be created via the Player.create function and will idle until one or more Sources are loaded. Once load is called, the player becomes active and initiates necessary downloads to start playback of the loaded source(s).

In case multiple sources were loaded into the player, Source.isActive identifies which source is currently active in the player (i.e. being played back). Only one source can be active at any time and API calls on the player will act on that source. More information on how to manage multiple sources can be found on the PlaylistApi.

The player emits events during its lifecycle. See EventEmitter on how to subscribe to events. Events are divided into PlayerEvent and SourceEvent, depending on if they are specific to a player session or a source. While SourceEvents are naturally emitted from a source, they are also emitted from the player for the active source. This allows for all event handling to be done through the player in case only a single source is loaded, enabling the same workflows as on v2 of the Bitmovin Player SDK, where it was not possible to load multiple sources and where each event was a PlayerEvent.

The player implements the RemoteControlApi, which offers the ability to connect to a cast-compatible device, allowing remote playback of the loaded sources.

By default, a player instance does not provide any UI components. To use the default Bitmovin Player Web UI, a player instance can be attached to a PlayerView. The PlayerView already comes with a Surface to render video into, a ViewGroup to display ads, the Bitmovin Player Web UI and handling for standard UI use-cases. If a custom UI is preferred, a Surface must be provided to the player via setSurface and a ViewGroup must be set via setAdViewGroup if advertising features are needed.

Types

Companion
Link copied to clipboard
object Companion

Properties

audio
Link copied to clipboard
abstract val audio: AudioTrack?
The currently selected AudioTrack or null if there is none.
audioQuality
Link copied to clipboard
abstract val audioQuality: AudioQuality?
The currently selected AudioTrack.
availableAudio
Link copied to clipboard
abstract val availableAudio: List<AudioTrack>
A list of all available AudioTracks of the active source.
availableAudioQualities
Link copied to clipboard
abstract val availableAudioQualities: List<AudioQuality>
A list of all available AudioQualitys of the active source.
availableSubtitles
Link copied to clipboard
abstract val availableSubtitles: List<SubtitleTrack>
A list of all available SubtitleTracks of the active source.
availableVideoQualities
Link copied to clipboard
abstract val availableVideoQualities: List<VideoQuality>
A list of all available VideoQualitys of the active source.
buffer
Link copied to clipboard
abstract val buffer: BufferApi
The BufferApi for interactions regarding the buffer.
config
Link copied to clipboard
abstract val config: PlayerConfig
The player config.
currentTime
Link copied to clipboard
abstract val currentTime: Double
The current playback time in seconds.
currentVideoFrameRate
Link copied to clipboard
abstract val currentVideoFrameRate: Float
The current video frame rate as frames per second.
droppedVideoFrames
Link copied to clipboard
abstract val droppedVideoFrames: Int
The total number of dropped frames since playback started.
duration
Link copied to clipboard
abstract val duration: Double
The duration of the active source in seconds if it's a VoD or Double.POSITIVE_INFINITY if it's a live stream.
isAd
Link copied to clipboard
abstract val isAd: Boolean
Returns true while an ad is being played back or when main content playback has been paused for ad playback.
isLive
Link copied to clipboard
abstract val isLive: Boolean
Whether the active and loaded source is a live stream.
isMuted
Link copied to clipboard
abstract val isMuted: Boolean
Whether the player is muted.
isPaused
Link copied to clipboard
abstract val isPaused: Boolean
Whether the player is paused.
isPlaying
Link copied to clipboard
abstract val isPlaying: Boolean
Whether the player is currently playing (i.e.
isStalled
Link copied to clipboard
abstract val isStalled: Boolean
Whether the player is currently stalling due to low buffer conditions.
lowLatency
Link copied to clipboard
abstract val lowLatency: LowLatencyApi
The LowLatencyApi for interactions regarding low latency.
maxTimeShift
Link copied to clipboard
abstract val maxTimeShift: Double
The limit in seconds for time shifting.
playbackAudioData
Link copied to clipboard
abstract val playbackAudioData: AudioQuality?
The AudioQuality that is currently being played back or null if no audio is currently being played back.
playbackSpeed
Link copied to clipboard
abstract var playbackSpeed: Float
The playback speed of the player.
playbackVideoData
Link copied to clipboard
abstract val playbackVideoData: VideoQuality?
The VideoQuality that is currently being played back or null if no video is currently being played back.
playlist
Link copied to clipboard
abstract val playlist: PlaylistApi
The PlaylistApi for interactions regarding the playlist.
source
Link copied to clipboard
abstract val source: Source?
The currently active Source or null if no source is active.
subtitle
Link copied to clipboard
abstract val subtitle: SubtitleTrack?
The currently selected SubtitleTrack or null if there is none.
timeShift
Link copied to clipboard
abstract val timeShift: Double
The current time shift of the live stream in seconds.
videoQuality
Link copied to clipboard
abstract val videoQuality: VideoQuality?
The currently selected VideoQuality.
volume
Link copied to clipboard
abstract var volume: Int
The player volume in the range 0 to 100.
vr
Link copied to clipboard
abstract val vr: VrApi
The VrApi for interacting with VR capabilities.

Inherited properties

isCastAvailable
Link copied to clipboard
abstract val isCastAvailable: Boolean
Whether casting to a cast-compatible remote device is available.
isCasting
Link copied to clipboard
abstract val isCasting: Boolean
Whether video is currently being casted to a remote device and not played locally.

Functions

destroy
Link copied to clipboard
abstract fun destroy()
Destroys the player and stops most internal work.
getThumbnail
Link copied to clipboard
abstract fun getThumbnail(time: Double): Thumbnail?
Returns a Thumbnail for the provided playback time or null if there is no thumbnail available.
load
Link copied to clipboard
abstract fun load(playlistConfig: PlaylistConfig)
Loads a playlist containing multiple Sources into the player.
abstract fun load(source: Source)
Loads a new Source into the player.
abstract fun load(sourceConfig: SourceConfig)
Loads a new Source based on the provided SourceConfig into the player.
mute
Link copied to clipboard
abstract fun mute()
Mutes the player if an audio track is available.
onPause
Link copied to clipboard
abstract fun onPause()
onResume
Link copied to clipboard
abstract fun onResume()
onStart
Link copied to clipboard
abstract fun onStart()
onStop
Link copied to clipboard
abstract fun onStop()
pause
Link copied to clipboard
abstract fun pause()
Pauses playback.
play
Link copied to clipboard
abstract fun play()
Starts playback or resumes after being paused.
preload
Link copied to clipboard
abstract fun preload()
Starts preloading the content of the currently active Source.
removeSubtitle
Link copied to clipboard
abstract fun removeSubtitle(trackId: String)
Removes the existing SubtitleTrack with trackId from the list of available subtitle tracks.
scheduleAd
Link copied to clipboard
abstract fun scheduleAd(adItem: AdItem)
Schedules the adItem for playback.
seek
Link copied to clipboard
abstract fun seek(time: Double)
Seeks to the given playback time in seconds.
setAdViewGroup
Link copied to clipboard
abstract fun setAdViewGroup(adViewGroup: ViewGroup?)
Sets the ViewGroup in which the ad and the ad UI should be created.
setAudio
Link copied to clipboard
abstract fun setAudio(trackId: String)
Enables the AudioTrack that corresponds to the trackId.
setAudioQuality
Link copied to clipboard
abstract fun setAudioQuality(qualityId: String)
Sets a fixed AudioQuality, identified by the qualityId.
setMaxSelectableVideoBitrate
Link copied to clipboard
abstract fun setMaxSelectableVideoBitrate(bitrate: Int)
Sets the upper bitrate boundary for video qualities to bitrate.
setSubtitle
Link copied to clipboard
abstract fun setSubtitle(trackId: String?)
Enables the SubtitleTrack that corresponds to the trackId.
setSurface
Link copied to clipboard
abstract fun setSurface(surface: Surface?)
Sets the Surface onto which video will be rendered.
abstract fun setSurface(surfaceHolder: SurfaceHolder?)
Sets the SurfaceHolder that holds the Surface onto which video will be rendered.
setVideoQuality
Link copied to clipboard
abstract fun setVideoQuality(qualityId: String)
Sets a fixed VideoQuality, identified by the qualityId.
skipAd
Link copied to clipboard
abstract fun skipAd()
Skips the current ad.
timeShift
Link copied to clipboard
abstract fun timeShift(offset: Double)
Shifts the time to the given offset in seconds from the live edge.
unload
Link copied to clipboard
abstract fun unload()
Unloads all Sources in the player.
unmute
Link copied to clipboard
abstract fun unmute()
Unmutes the player it it is muted.

Inherited functions

castStop
Link copied to clipboard
abstract fun castStop()
Stops casting the current video.
castVideo
Link copied to clipboard
abstract fun castVideo()
Initiates casting the current video to a cast-compatible remote device.
next
Link copied to clipboard
open override fun <E : Event> next(eventClass: Class<E>, eventListener: EventListener<E>)
Subscribes the eventListener to be executed when the next event of type E is emitted.
abstract fun <E : Event> next(eventClass: KClass<E>, action: (E) -> Unit)
Subscribes the action to be executed when the next event of type E is emitted.
off
Link copied to clipboard
open override fun <E : Event> off(eventListener: EventListener<E>)
Unsubscribes the eventListener for all events.
abstract fun <E : Event> off(action: (E) -> Unit)
Unsubscribes the action for all events.
open override fun <E : Event> off(eventClass: Class<E>, eventListener: EventListener<E>)
Unsubscribes the eventListener for the specified event.
abstract fun <E : Event> off(eventClass: KClass<E>, action: (E) -> Unit)
Unsubscribes the action for the specified event.
on
Link copied to clipboard
open override fun <E : Event> on(eventClass: Class<E>, eventListener: EventListener<E>)
Subscribes the eventListener to be executed when an event of type E is emitted.
abstract fun <E : Event> on(eventClass: KClass<E>, action: (E) -> Unit)
Subscribes the action to be executed when an event of type E is emitted.