Bitmovin Player React Native SDK - v1.31.0
    Preparing search index...

    Class Player

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

    Can be attached to PlayerView component in order to use Bitmovin's Player Web UI.

    PlayerView

    Hierarchy

    Index
    analytics?: AnalyticsApi = undefined

    The AnalyticsApi for interactions regarding the Player's analytics.

    undefined if the player was created without analytics support.

    buffer: BufferApi = ...

    The BufferApi for interactions regarding the buffer.

    config?: PlayerConfig

    The configuration object used to initialize this instance.

    isDestroyed: boolean = false

    Whether the native Player object has been disposed.

    isInitialized: boolean = false

    Whether the native Player object has been created.

    mediaControls: MediaControlsApi = ...

    The MediaControlsApi for interactions regarding the Player's media controls integration.

    iOS, tvOS

    nativeId: string

    Optionally user-defined string id for the native instance, or UUIDv4.

    playlist: PlaylistApi = ...

    The PlaylistApi for interactions regarding the playlist of the playback session.

    • Checks the possibility to play the media at specified playback speed.

      Parameters

      • playbackSpeed: number

        The playback speed to check.

      Returns Promise<boolean | undefined>

      true if it's possible to play the media at the specified playback speed, otherwise false. On Android it always returns undefined.

      iOS, tvOS

    • Stops casting the current video. Has no effect if Player.isCasting is false.

      Returns void

      iOS, Android

    • Initiates casting the current video to a cast-compatible remote device. The user has to choose to which device it should be sent.

      Returns void

      iOS, Android

    • Destroys the native Player and releases all of its allocated resources.

      Also destroys every Source this player was the last to load or add to its playlist, including ones it no longer plays, e.g. after Player.unload or a later load. A source loaded into another player since, or removed via PlaylistApi.remove or PlaylistApi.removeAt, is not destroyed.

      Known limitations:

      • Sources that left the player through Player.unload or a later load stay allocated until the player is destroyed.
      • Source.on listeners do not receive the final sourceUnloaded when the player is destroyed.

      Returns void

    • Returns an array containing all available video qualities the player can adapt between.

      Returns Promise<VideoQuality[]>

      An array containing all available video qualities the player can adapt between.

    • Parameters

      • mode: "relative" | "absolute" = 'absolute'

        The time mode to specify: an absolute UNIX timestamp ('absolute') or relative time ('relative').

      Returns Promise<number>

      The current playback time in seconds.

      For VoD streams the returned time ranges between 0 and the duration of the asset.

      For live streams it can be specified if an absolute UNIX timestamp or a value relative to the playback start should be returned.

    • Returns Promise<number>

      The total duration in seconds of the current video or INFINITY if it’s a live stream.

    • The limit in seconds for time shifting. This value is either negative or 0 and it is always 0 if the active Source is not a live stream or no sources are loaded.

      Returns Promise<number>

    • Returns Promise<number>

      The player's current playback speed.

      setPlaybackSpeed for details on which values playback speed can assume.

    • Gets the currently active Source of the playback session.

      Returns Promise<Source | undefined>

      the active source, or undefined if there is no active playback session or the active source was not created through a Source instance (e.g. offline content).

    • Parameters

      • time: number

        The time in seconds for which to retrieve the thumbnail.

      Returns Promise<Thumbnail | null>

      a Thumbnail for the specified playback time for the currently active source if available. Supported thumbnail formats are:

      • WebVtt configured via SourceConfig.thumbnailTrack, on all supported platforms
      • HLS Image Media Playlist in the multivariant playlist, Android-only
      • DASH Image Adaptation Set as specified in DASH-IF IOP, Android-only If a WebVtt thumbnail track is provided, any potential in-manifest thumbnails are ignored on Android.
    • The current time shift of the live stream in seconds. This value is always 0 if the active Source is not a live stream or no sources are loaded.

      Returns Promise<number>

    • Returns Promise<number>

      The player's current volume level.

    • Allocates the native Player instance and its resources natively. Calls made while an initialization is in progress share it.

      Returns Promise<void>

    • Returns Promise<boolean>

      true while an ad is being played back or when main content playback has been paused for ad playback. false while a pause ad is shown.

      iOS, Android

    • Returns Promise<boolean>

      true when media is played externally using AirPlay.

      iOS

    • Returns Promise<boolean>

      true when AirPlay is available.

      iOS

    • Whether casting to a cast-compatible remote device is available. CastAvailableEvent signals when casting becomes available.

      Returns Promise<boolean>

      iOS, Android

    • Whether video is currently being casted to a remote device and not played locally.

      Returns Promise<boolean>

      iOS, Android

    • Returns Promise<boolean>

      true if the displayed video is a live stream.

    • Returns Promise<boolean>

      true if the player is muted.

    • Returns Promise<boolean>

      true if the player has started playback but it's currently paused.

    • Returns Promise<boolean>

      true if the player is currently playing, i.e. has started and is not paused.

    • Experimental

      Starts a new playback session consisting of PlaylistConfig.sources. The first source becomes active immediately. An already active playback session is unloaded first.

      Only one source is active at a time and all player APIs (e.g. time, duration, seeking) act on the active source; there is no playlist-wide time. Source events of inactive sources, such as SourceLoaded of a preloaded source, are not emitted by the player; use Source.on to receive them. Only sourceError is also emitted for inactive sources, without identifying the source. Ads scheduled via the advertising config only apply to the first source.

      On iOS and tvOS, only HLS, progressive and movpkg sources can be part of a playlist.

      The player destroys the sources when it is destroyed, unless they were loaded into another player since or removed via PlaylistApi.remove or PlaylistApi.removeAt; see Player.destroy.

      Throws if sources is empty or contains a source more than once, options.replayMode is unknown, a source was destroyed, or (on iOS and tvOS) a source has an unsupported type.

      Known limitations:

      See Player.destroy for all known limitations of the source lifecycle.

      Parameters

      Returns void

    • Mutes the player if an audio track is available. Has no effect if the player is already muted.

      Returns void

    • Registers listener to be called whenever the player emits eventName, independent of any PlayerView. The player emits its own events and the source events of the active source only, except sourceError, which it also emits for inactive sources without identifying the source; use Source.on for events of a specific source, including while it is inactive.

      Listeners registered before the player is initialized are attached during Player.initialize, and listeners registered before loading receive the events of that load, such as playerActive. All listeners are removed when the player is destroyed. Calling it on a destroyed player has no effect and logs a warning. Registering the same listener again for eventName has no effect; use Player.off to remove it.

      Type Parameters

      Parameters

      • eventName: K

        The name of the event, e.g. playerActive.

      • listener: (event: PlayerEventMap[K]) => void

        The function called with the event.

      Returns void

    • Pauses the video if it is playing. Has no effect if the player is already paused.

      Returns void

    • Starts or resumes playback after being paused. Has no effect if the player is already playing.

      Returns void

    • Dynamically schedules the AdItem for playback. Has no effect if there is no active playback session.

      Parameters

      • adItem: AdItem

        Ad to be scheduled for playback.

      Returns void

      iOS, Android

    • Seeks to the given playback time specified by the parameter time in seconds. Must not be greater than the total duration of the video. Has no effect when watching a live stream since seeking is not possible.

      Parameters

      • time: number

        The time to seek to in seconds.

      Returns void

    • Sets the audio track to the ID specified by trackIdentifier. A list can be retrieved by calling getAvailableAudioTracks.

      Parameters

      Returns Promise<void>

    • Sets the upper bitrate boundary for video qualities. All qualities with a bitrate that is higher than this threshold will not be eligible for automatic quality selection.

      Can be set to null for no limitation.

      Parameters

      • bitrate: number | null

      Returns void

    • Sets the playback speed of the player. Fast forward, slow motion and reverse playback are supported.

      Parameters

      • playbackSpeed: number

        The playback speed to set.

      Returns void

      Platform: iOS, tvOS

      • Slow motion is indicated by values between 0 and 1.
      • Fast forward by values greater than 1.
      • Slow reverse is used by values between 0 and -1, and fast reverse is used by values less than -1. iOS and tvOS only.
      • Negative values are ignored during Casting and on Android.
      • During reverse playback the playback will continue until the beginning of the active source is reached. When reaching the beginning of the source, playback will be paused and the playback speed will be reset to its default value of 1. No PlaybackFinishedEvent will be emitted in this case.
    • Sets the subtitle track to the ID specified by trackIdentifier. A list can be retrieved by calling getAvailableSubtitles. Pass undefined to disable subtitles.

      Parameters

      Returns Promise<void>

    • Sets the video quality.

      Parameters

      • qualityId: string

        value obtained from VideoQuality's id property, which can be obtained via Player.getAvailableVideoQualities() to select a specific quality. To use automatic quality selection, 'auto' can be passed here.

      Returns void

      Android

    • Sets the player's volume between 0 (silent) and 100 (max volume).

      Parameters

      • volume: number

        The volume level to set.

      Returns void

    • Displays the system AirPlay route selection menu, allowing the user to pick an AirPlay target for the current playback.

      Returns void

      iOS

    • Skips the current ad. Has no effect if the current ad is not skippable or if no ad is being played back.

      Also dismisses a visible pause ad. The main content stays paused.

      Returns void

      iOS, Android

    • Shifts the time to the given offset in seconds from the live edge. The resulting offset has to be within the timeShift window as specified by maxTimeShift (which is a negative value) and 0. When the provided offset is positive, it will be interpreted as a UNIX timestamp in seconds and converted to fit into the timeShift window. When the provided offset is negative, but lower than maxTimeShift, then it will be clamped to maxTimeShift. Has no effect for VoD.

      Has no effect if no sources are loaded.

      Parameters

      • offset: number

        Target offset from the live edge in seconds.

      Returns void

    • Unmutes the player if it is muted. Has no effect if the player is already unmuted.

      Returns void