Skip to main content

Web Player SDK API Reference

BlendVision One Web Player SDK API Reference

Overview

Interfaces

Functions

Functions

createPlayer

createPlayer(targetId, config): Player

Create/initialize a player instance

Parameters

NameTypeDescription
targetIdstringThe target element ID.
configanyThe config object passed to the Premium Player constructor.

Returns

Player

instance of the player

Methods

UI

Methods

addEventListener

addEventListener(type, listener): void

Add event listener to player.

Parameters

NameTypeDescription
typestringThe event type
listeneranyThe event handler

Returns

void


currentTime

currentTime(): undefined | number

Get the current playback time in milliseconds of the video.

Returns

undefined | number

Current playback time.


forward

forward(seconds?): void

Forward to the given playback time specified by the parameter time in seconds. Must not be greater than the total duration of the video.

Parameters

NameTypeDefault valueDescription
secondsnumber10Seconds to seek forward / 10 seconds by default.

Returns

void


getAudioTracks

getAudioTracks(): undefined | MediaTrack[]

Get an array of all available audio tracks.

Returns

undefined | MediaTrack[]


getCurrentAudioTrack

getCurrentAudioTrack(): undefined | MediaTrack

Get the currently selected audio track, if the user manually selected one. In this case it returns one of the elements of getAudioTracks.

Returns

undefined | MediaTrack


getCurrentQuality

getCurrentQuality(): undefined | Quality

Get the currently selected video quality, if the user manually selected one. In this case it returns one of the elements of getQualities.

Returns

undefined | Quality


getCurrentSubtitle

getCurrentSubtitle(): undefined | string | MediaTrack

Get the currently selected subtitle, if the user manually selected one. In this case it returns one of the elements of getSubtitles.

Returns

undefined | string | MediaTrack


getDuration

getDuration(): undefined | number

Get the total duration in milliseconds of the current video. There's no reference value if it's a live stream.

Returns

undefined | number

duration of the video, -1 if playing a live stream.


getPlaybackSpeed

getPlaybackSpeed(): undefined | number

Geturns 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

undefined | number

Current playback speed.


getQualities

getQualities(): Quality[]

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

Returns

Quality[]


getSubtitles

getSubtitles(): undefined | MediaTrack[]

Get an array of all available subtitles.

Returns

undefined | MediaTrack[]


getVolume

getVolume(): undefined | number

Get the player’s volume between 0.0 (silent) and 1.0 (max volume) by floating type.

Returns

undefined | number


load

load(sourceToSet): Promise<object>

Set a new video source and returns a promise which resolves to the player

Parameters

NameTypeDescription
sourceToSetstring | { load: string | object ; type: string } | { load: string | object ; type: string }[]This method updates the video source

Returns

Promise<object>


mute

mute(): void

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

Returns

void


pause

pause(): void

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

Returns

void


play

play(): Promise<object>

Start playback or resumes after being paused. No need to call it if the player is set autoplay as true during initialize player. Has no effect if the player is already playing.

Returns

Promise<object>


release

release(): void

Destroy the player and removes all inserted HTML elements and event handlers.

Returns

void


rewind

rewind(seconds?): void

Rewind to the given playback time specified by the parameter time in seconds. Must not be greater than the total duration of the video.

Parameters

NameTypeDefault valueDescription
secondsnumber10Seconds to rewind / 10 seconds by default.

Returns

void


seek

seek(time): number | void

Seek 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

NameTypeDescription
timenumberPlayback time to set in seconds

Returns

number | void

Current playback time


setAudioTrack

setAudioTrack(language): void

Manually set the audio track to a specified language. Available tracks can be retrieved with getAudioTracks.

Parameters

NameTypeDescription
languagestringThe language of audio

Returns

void


setPlaybackSpeed

setPlaybackSpeed(value): void

Set 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, and fast forward by values greater than 1.

Parameters

NameTypeDescription
valuenumberThe playback speed of the player from 0.25 to 4.

Returns

void


setQuality

setQuality(restrictions): void

Manually set the video stream to a fixed quality, e.g. height range, specified bitrate or null (means auto resets to dynamic switching). A list can be retrieved by calling getQualities.

Parameters

NameType
restrictionsRestrictions

Returns

void


setSubtitle

setSubtitle(track): void

Manually set the subtitle to a specified language or turn-off. Available subtitles can be retrieved with getSubtitles.

Parameters

NameTypeDescription
trackstringThe language of subtitle

Returns

void


setVolume

setVolume(value): undefined | null

Set the player’s volume in the range of 0.0 (silent) to 1.0 (max volume). Unmutes a muted player.

Parameters

NameTypeDescription
valuenumberThe volume level of the player from 0 to 1.

Returns

undefined | null


unmute

unmute(): void

Unmute the player if muted.

Returns

void


volume

volume(value): void

This method sets the volume level of the player on a scale from 0 to 1.

Parameters

NameTypeDescription
valuenumberThe volume level of the player from 0 to 1.

Returns

void

UI

setCoverImage

setCoverImage(imageUrl): void

Parameters

NameType
imageUrlstring

Returns

void


setViewMode

setViewMode(viewMode): void

Set view mode.

Parameters

NameTypeDescription
viewMode"fullscreen" | "inline"view mode

Returns

void


switchControlMode

switchControlMode(mode): void

Set the UI state if mode is given, or get current UI mode.

Parameters

NameTypeDescription
modestringDesired UI mode.

Returns

void

Media Track

Table of contents

Properties

language

Optional language: string


name

Optional name: string

Quality

Table of contents

Properties

bitrate

bitrate: number


framerate

framerate: number


height

height: number


width

width: number

Restrictions

Table of contents

Properties

maxHeight

maxHeight: number


minHeight

minHeight: number