Interface WrappedPlayer

Extended interface of the Player for use in the UI.

interface WrappedPlayer {
    adaptation: AdaptationAPI;
    ads: PlayerAdvertisingAPI;
    buffer: PlayerBufferAPI;
    drm: DrmAPI;
    exports: PlayerExports;
    lowlatency: LowLatencyAPI;
    manifest: PlayerManifestAPI;
    subtitles: PlayerSubtitlesAPI;
    version: string;
    vr: PlayerVRAPI;
    addMetadata(metadataType: CAST, metadata: any): boolean;
    castStop(): void;
    castVideo(): void;
    clearQueryParameters(): void;
    destroy(): Promise<void>;
    fireEventInUI(event: PlayerEvent, data: {}): void;
    getAspectRatio(): number;
    getAudio(): AudioTrack;
    getAudioBufferLength(): number;
    getAudioQuality(): AudioQuality;
    getAvailableAudio(): AudioTrack[];
    getAvailableAudioQualities(): AudioQuality[];
    getAvailableSegments(): SegmentMap;
    getAvailableVideoQualities(): VideoQuality[];
    getBufferedRanges(): TimeRange[];
    getConfig(mergedConfig?: boolean): PlayerConfig;
    getContainer(): HTMLElement;
    getCurrentTime(mode?: TimeMode): number;
    getDownloadedAudioData(): DownloadedAudioData;
    getDownloadedVideoData(): DownloadedVideoData;
    getDroppedVideoFrames(): number;
    getDuration(): number;
    getManifest(): string;
    getMaxTimeShift(): number;
    getPlaybackAudioData(): AudioQuality;
    getPlaybackSpeed(): number;
    getPlaybackVideoData(): VideoQuality;
    getPlayerType(): PlayerType;
    getSeekableRange(): TimeRange;
    getSnapshot(type?: string, quality?: number): Snapshot;
    getSource(): SourceConfig;
    getStreamType(): StreamType;
    getSupportedDRM(): Promise<string[]>;
    getSupportedTech(mode?: SupportedTechnologyMode): Technology[];
    getThumbnail(time: number): Thumbnail;
    getTimeShift(): number;
    getTotalStalledTime(): number;
    getVideoBufferLength(): number;
    getVideoElement(): HTMLVideoElement;
    getVideoQuality(): VideoQuality;
    getViewMode(): ViewMode;
    getVolume(): number;
    hasEnded(): boolean;
    isAirplayActive(): boolean;
    isAirplayAvailable(): boolean;
    isCastAvailable(): boolean;
    isCasting(): boolean;
    isDRMSupported(drmSystem: string): Promise<string>;
    isLive(): boolean;
    isMuted(): boolean;
    isPaused(): boolean;
    isPlaying(): boolean;
    isStalled(): boolean;
    isViewModeAvailable(viewMode: ViewMode): boolean;
    load(source: SourceConfig, forceTechnology?: string, disableSeeking?: boolean): Promise<void>;
    mute(issuer?: string): void;
    off(eventType: PlayerEvent, callback: PlayerEventCallback): void;
    on(eventType: PlayerEvent, callback: PlayerEventCallback): void;
    pause(issuer?: string): void;
    play(issuer?: string): Promise<void>;
    preload(): void;
    seek(time: number, issuer?: string): boolean;
    setAspectRatio(aspectratio: string | number): void;
    setAudio(trackID: string): void;
    setAudioQuality(audioQualityID: string): void;
    setAuthentication(customData: any): void;
    setLogLevel(level: LogLevel): void;
    setPlaybackSpeed(speed: number): void;
    setPosterImage(url: string, keepPersistent: boolean): void;
    setQueryParameters(queryParameters: QueryParameters): void;
    setVideoElement(videoElement: HTMLElement): void;
    setVideoQuality(videoQualityID: string): void;
    setViewMode(viewMode: ViewMode, options?: ViewModeOptions): void;
    setVolume(volume: number, issuer?: string): void;
    showAirplayTargetPicker(): void;
    timeShift(offset: number, issuer?: string): void;
    unload(): Promise<void>;
    unmute(issuer?: string): void;
}

Hierarchy

  • PlayerAPI
    • WrappedPlayer

Properties

adaptation: AdaptationAPI

The adaptation API namespace.

ads: PlayerAdvertisingAPI

The advertising API namespace.

buffer: PlayerBufferAPI

The buffer API namespace.

drm: DrmAPI

The DRM API namespace.

exports: PlayerExports

Exports from the player core as a convenience fallback for non-modular code. It is recommended to use ES6 imports instead.

Usage:

import { Player } from 'bitmovin-player';
const player = new Player(...);
player.on(player.exports.Event.Loaded, () => ...);

Recommended approach:

import { Player, Event } from 'bitmovin-player';
const player = new Player(...);
player.on(Event.Loaded, () => ...);

It is recommended to use ES6 imports instead

lowlatency: LowLatencyAPI

The low latency API namespace.

manifest: PlayerManifestAPI

The manifest API namespace.

subtitles: PlayerSubtitlesAPI

The subtitles API namespace.

version: string

The version number of the player.

vr: PlayerVRAPI

The VR API namespace.

Methods

  • Sends custom metadata to a remote receiver app (e.g. Chromecast).

    Parameters

    • metadataType: CAST

      The type of the metadata. Currently only 'CAST' is supported.

    • metadata: any

      The custom data to send to the receiver.

    Returns boolean

    True if it was successful.

    v4.0

  • Stops a running Cast session (i.e. isCasting returns true). Has no effect if isCasting returns false.

    Returns void

    v4.0

  • Initiates casting the current video to a Cast-compatible device. The user has to choose the target device.

    Returns void

    v4.0

  • Removes all existing query parameters as specified in setQueryParameters or TweaksConfig.query_parameters.

    Returns void

    v4.0

  • Unloads the player and removes all inserted HTML elements and event handlers.

    Returns Promise<void>

    Promise resolves when the player has cleaned up all its event handlers & resources

    v8.0

  • Fires an event on the player that targets all handlers in the UI but never enters the real player.

    Parameters

    • event: PlayerEvent

      the event to fire

    • data: {}

      data to send with the event

      Returns void

    • Returns the current aspect ratio of the player, or 0 if there is no style module. Note: the default player aspect ratio is 16:9.

      Returns number

      A number indicating the player aspect ratio (e.g. 1.6 for 16:10).

      v8.74

    • Returns the currently used audio track, or null if no track is active.

      Returns AudioTrack

      v4.0

    • Returns the seconds of already buffered audio data or null if no audio source is loaded.

      Returns number

      Use PlayerBufferAPI.getLevel instead.

    • Returns the currently selected audio quality. One of the elements of getAvailableAudioQualities.

      Returns AudioQuality

      v7.3.1

    • Returns an array of all available audio tracks.

      Returns AudioTrack[]

      v4.0

    • Returns an array of all available audio qualities the player can adapt between.

      Returns AudioQuality[]

      v4.0

    • Returns infos for segments that can be requested by the player

      Returns SegmentMap

      v7.2

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

      Returns VideoQuality[]

      v4.0

    • Returns the currently buffered time ranges of the video element.

      Returns TimeRange[]

      v6.1

    • Returns the config object of the current player instance.

      Parameters

      • OptionalmergedConfig: boolean

        true to return the config expanded with all default values, false to return the user config passed to the player's constructor.

      Returns PlayerConfig

      The current user or merged player config.

      v4.0

    • Returns the html element that the player is embedded in, which has been provided in the player constructor.

      Returns HTMLElement

      v8.0

    • Returns the current playback time in seconds of the video.

      Parameters

      • Optionalmode: TimeMode

        The mode to decide if the returned time should be absolute or relative, see TimeMode. Default mode is absolute.

      Returns number

      v4.0

    • Returns data about the last downloaded audio segment.

      Returns DownloadedAudioData

      v4.0

    • Returns data about the last downloaded video segment.

      Returns DownloadedVideoData

      v4.0

    • Returns the total number of dropped video frames since playback started.

      Returns number

      v8.0

    • Returns the total duration in seconds of the current video or {@code Infinity} if it’s a live stream.

      Returns number

      v4.0

    • Returns the used DASH or HLS manifest file.

      Previous player versions (v4.2-v7.0) returned an object for DASH and a string for HLS, this has been corrected in v7.1.

      Returns string

      v7.1

    • Returns the limit in seconds for time shift. Is either negative or 0 and applicable to live streams only.

      Returns number

      v4.0

    • Returns data about the currently playing audio segment.

      Returns AudioQuality

      v4.0

    • Returns the current playback speed of the player. 1 is the default playback speed, values between 0 and 1 refer to slow motion and values greater than 1 refer to fast forward. Values less or equal zero are ignored.

      Returns number

      v4.0

    • Returns data about the currently playing video segment.

      Returns VideoQuality

      v4.0

    • Returns the currently used rendering mode. See PlayerType for details of the valid values.

      Returns PlayerType

      v4.0

    • Returns the time range that is currently valid for seeking.

      Returns TimeRange

      v7.1

    • Creates a snapshot of the current video frame. Snapshots cannot be taken from DRM protected content.

      Parameters

      • Optionaltype: string

        The type of image snapshot to capture. Allowed values are 'image/jpeg' and 'image/webp'.

      • Optionalquality: number

        A number between 0 and 1 indicating the image quality.

      Returns Snapshot

      v4.0

    • Gets the source that was loaded via a successfully finished load call or null if no source is loaded or a load is in progress.

      Returns SourceConfig

      the loaded source or null if no source is loaded

    • Returns the currently used streaming technology. See StreamType for details of the valid values.

      Returns StreamType

      v4.0

    • Tests and retrieves a list of all supported DRM systems in the current user agent.

      Returns Promise<string[]>

      A Promise that resolves to an array of strings with the supported DRM systems after fulfillment. Should never be rejected.

      v4.1

    • Returns an array of objects denoting a player and streaming technology combination. By default, this returns the combinations supported on the current platform (SupportedTechnologyMode.Platform), ordered by descending priority which will be used to play a stream.

      Parameters

      • Optionalmode: SupportedTechnologyMode

        the mode by which the supported technologies are determined

      Returns Technology[]

      v4.0

    • Returns a thumbnail image for a certain time or null if there is no thumbnail available. Requires a configured thumbnails track in SourceConfig.thumbnailTrack.

      Parameters

      • time: number

        the media time for which the thumbnail should be returned

      Returns Thumbnail

      A thumbnail if a thumbnails track is configured and a thumbnail exists for the specified time, else null

      v8.0

    • Returns the current time shift offset to the live edge in seconds. Only applicable to live streams.

      Returns number

      v4.0

    • Returns the stalled time in seconds since playback started.

      Returns number

      v4.0

    • Returns the seconds of already buffered video data or null if no video source is loaded.

      Returns number

      Use PlayerBufferAPI.getLevel instead.

    • Returns the used HTML5 video element.

      Returns HTMLVideoElement

      The HTML5 video element which is used by the player

    • Returns the currently selected video quality, if the user manually selected one. In this case it returns one of the elements of getAvailableVideoQualities.

      In case the user did not select a video quality it returns auto.

      Returns VideoQuality

      v7.3.1

    • Gets the active ViewMode.

      Returns ViewMode

      the view mode that is currently active

      v8.0

    • Returns the player’s volume between 0 (silent) and 100 (max volume).

      Returns number

      v4.0

    • Returns true if the video has ended.

      Returns boolean

      v4.0

    • Checks if Apple Airplay is enabled.

      Returns boolean

      v7.8.4

    • Checks if Apple AirPlay support is available.

      Returns boolean

      v7.1

    • Returns true if casting to another device (such as a ChromeCast) is available, otherwise false. Please note that this function only returns true after the PlayerEvent.CastAvailable event has fired.

      Returns boolean

      v5.2

    • Returns true if the video is currently casted to a device and not played in the browser, or false if the video is played locally.

      Returns boolean

      v4.0

    • Checks if a DRM system is supported in the current user agent.

      Parameters

      • drmSystem: string

        A KeySystem string to test against

      Returns Promise<string>

      Resolves with the DRM system string if it is supported, or rejects with an error message if not

      v4.1

    • Return true if the displayed video is a live stream.

      Returns boolean

      v4.0

    • Returns true if the player has been muted.

      Returns boolean

      v4.0

    • Returns true if the player has started playback but is currently paused.

      Returns boolean

      v4.0

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

      Returns boolean

      v4.0

    • Returns true if the player is currently stalling due to an empty buffer.

      Returns boolean

      v4.0

    • Tests if a particular ViewMode is available for selection with setViewMode.

      Parameters

      • viewMode: ViewMode

        the view mode to test

      Returns boolean

      true if the tested view mode is available, else false

      v8.0

    • Sets a new video source and returns a promise which resolves to the player.

      Parameters

      • source: SourceConfig

        The source the player should load.

      • OptionalforceTechnology: string

        Forces the player to use the specified playback and streaming technology. The specified technologies have to be separated by a period (e.g. 'html5.hls'). A list of valid combinations can be retrieved by calling getSupportedTech.

      • OptionaldisableSeeking: boolean

        If set, seeking will be disabled

      Returns Promise<void>

      v4.0

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

      Parameters

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns void

      v4.0

    • Removes a handler for a player event. This method was called removeEventHandler in previous player versions.

      Parameters

      • eventType: PlayerEvent

        The event to remove the handler from

      • callback: PlayerEventCallback

        The callback handler to remove

      Returns void

      v7.8

    • Subscribes an event handler to a player event. This method was called addEventHandler in previous player versions.

      Parameters

      • eventType: PlayerEvent

        The type of event to subscribe to.

      • callback: PlayerEventCallback

        The event callback handler that will be called when the event fires.

      Returns void

      v7.8

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

      Parameters

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns void

      v4.0

    • Starts playback or resumes after being paused. No need to call it if the player is setup with autoplay attribute (PlaybackConfig.autoplay). Has no effect if the player is already playing.

      Parameters

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns Promise<void>

      a Promise which resolves as soon as playback has actually started. This promise can reject if play is prohibited by the browser (a missing user interaction for example)

      v4.0

    • Starts preloading the content of the currently loaded source.

      Returns void

      v6.1

    • 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 as seeking is not possible.

      Parameters

      • time: number

        The time to seek to

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns boolean

      v4.0

    • Modifies the current aspect ratio of the player. Can be used to override the StyleConfig.aspectratio that is optionally passed during player initialization. Has no effect if the player has also been configured to have a fixed StyleConfig.width and StyleConfig.height: in general, no more than two options among width, height, and aspectratio should be provided to the player.

      Parameters

      • aspectratio: string | number

        The desired aspect ratio for the player. It can be a string (e.g. '16:9' or '16/9'), or a number (e.g 1.6 for 16:10).

      Returns void

      v8.74

    • Sets the audio track to the ID specified by trackID. Available tracks can be retrieved with getAvailableAudio.

      Parameters

      • trackID: string

        The ID of the audio track to activate

      Returns void

      v4.0

    • Manually sets the audio stream to a fixed quality, identified by ID. Has to be an ID defined in the MPD or the keyword 'auto'. Auto resets to dynamic switching. A list with valid IDs can be retrieved by calling getAvailableAudioQualities.

      Parameters

      • audioQualityID: string

        The ID of the desired audio quality or 'auto' for dynamic switching

      Returns void

      v4.0

    • Sets authentication data which is sent along with the licensing call. Can be used to add more information for a 3rd party licensing backend. The data be any type or object as needed by the 3rd party licensing backend.

      Parameters

      • customData: any

        Data which should be sent with the licensing call

      Returns void

      v4.2

    • Sets the level of player log outputs.

      Parameters

      • level: LogLevel

        Log level, allowed values are "debug", "log", "warn", "error" and "off"

      Returns void

      v6.1

    • [HTML5 only] Sets the playback speed of the player. Fast forward as well as slow motion is supported. Slow motion is used by values between 0 and 1, fast forward by values greater than 1.

      Parameters

      • speed: number

        A playback speed factor greater than 0

      Returns void

      getPlaybackSpeed

      v4.0

    • Sets a poster image. Will be displayed immediately, even if a video stream is playing.

      Parameters

      • url: string

        The URL to the poster image

      • keepPersistent: boolean

        Flag to set the poster image persistent so it is also displayed during playback (useful for audio-only playback)

      Returns void

      v4.3

    • Adds GET parameters to all request URLs (e.g. manifest, media segments, subtitle files, …). The queryParameters should be an object with key value pairs, where the keys are used as parameter name and the values as parameter values.

      Parameters

      • queryParameters: QueryParameters

        The list of query parameter key/value pairs

      Returns void

      v4.1

    • Passes an HTML video element to the player, which should be used in case of Html5 or Native playback. Needs to be called before load.

      Parameters

      • videoElement: HTMLElement

        The HTML video element to use

      Returns void

      v5.1

    • Manually sets the video stream to a fixed quality, identified by ID. Has to be an ID defined in the MPD or the keyword 'auto'. Auto resets to dynamic switching. A list with valid IDs can be retrieved by calling getAvailableVideoQualities.

      Parameters

      • videoQualityID: string

        ID defined in the MPD or 'auto'

      Returns void

      v4.0

    • Sets the player to a particular ViewMode. Will only work if the selected view mode is available and isViewModeAvailable returns true, else this call will be ignored. If successful, a PlayerEvent.ViewModeChanged will be fired.

      Parameters

      • viewMode: ViewMode

        the view mode to switch the player into

      • Optionaloptions: ViewModeOptions

        additional optional parameters for view modes

      Returns void

      v8.0

    • Sets the player’s volume in the range of 0 (silent) to 100 (max volume). Unmutes a muted player.

      Parameters

      • volume: number

        The volume to set between 0 and 100

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns void

      v4.0

    • Shows the airplay playback target picker.

      Returns void

      v7.1

    • Shifts the time to the given offset in seconds from the live edge. Has to be within getMaxTimeShift (which is a negative value) and 0. Only works in live streams. [new in v4.3]: The offset can be positive and is then interpreted as a UNIX timestamp in seconds. The value has to be within the timeShift window as specified by getMaxTimeShift.

      Parameters

      • offset: number

        The offset to timeshift to

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns void

      v4.0

    • Unloads the current video source.

      Returns Promise<void>

      v4.0

    • Unmutes the player if muted.

      Parameters

      • Optionalissuer: string

        The issuer of the API call that will be passed to events triggered by this call

      Returns void

      v4.0