All Products
Search
Document Center

Configurations

Last Updated: May 19, 2022

This topic describes the configurations used to implement LinkVisual Player for web.

Options provided by Video.js

Video.js is an open source JavaScript library for embedding video players on web pages. For all options provided by Video.js, see Video.js Documentation.

Option

Required

Type

Description

autoplay

No

Boolean or String

Specifies whether to enable autoplay after the player is initialized. Valid values:

  • true: enables autoplay.

  • false: disables autoplay. This is the default value.

Note

You can also set the option to 'muted', 'play', or 'any'. For more information, see the description of the autoplay option in Video.js Options Reference.

muted

No

Boolean

Specifies whether to enable muting. Valid values:

  • true: enables muting.

  • false: disables muting. This is the default value.

Notice

If you want the video to be played immediately after it is loaded, set the option to true. This prevents the browser from blocking the video from playing.

controls

No

Boolean

Specifies whether to configure a control bar for the player. Valid values:

  • true: configures a control bar. This is the default value.

  • false: does not configure a control bar.

Note

If this option is set to false, you can only control video playback by calling methods.

height

No

Number or String

The height of the web player. You can specify a string or a number. For example, you can set the option to '300px' or 300.

width

No

Number or String

The width of the web player. You can specify a string or a number. For example, you can set the option to '300px' or 300.

preload

No

String

Specifies whether to preload the video. Valid values:

  • auto: automatically preloads the video.

  • metadata: preloads the metadata of the video, such as the duration and image size.

  • none: does not preload the video. The video is downloaded only when the playback starts.

loop

No

Boolean

Specifies whether to enable loop playback. Valid values:

  • true: enables loop playback.

  • false: disables loop playback. This is the default value.

techOrder

Yes

Array

The order in which Video.js techs are preferred. In this example, set this option to ['flv', 'html5'].

children

No

Array or Object

Specifies the children that the player includes and the order in which they are created.

poster

No

String

The URL of an image that is displayed before the playback starts. The image disappears as soon as the playback starts.

FLV-related parameters

Parameter

Required

Type

Description

flv

Yes

Object

The configurations related to Flash Video (FLV).

reconnInterval

Yes

Number

The interval between two consecutive reconnections. Unit: milliseconds. For example, set this parameter to 5000.

reconnTimes

Yes

Number

The number of reconnections allowed if the playback fails. For example, set this parameter to 10.

getStreamUrl

Yes

Function

Returns a streaming URL or a promise that returns the streaming URL.

mediaDataSource

No

Object

The configurations related to the playback source.

For more information, see mediaDataSource.

flvConfig

Yes

Object

The configurations related to the FLV-based playback.

For more information, see flvConfig.

mediaDataSource

Parameter

Required

Type

Description

isLive

No

Boolean

Specifies whether the playback source is a live stream. Valid values:

  • true: The playback source is a live stream.

  • false: The playback source is not a live stream.

cors

No

Boolean

Specifies whether to enable cross-origin resource sharing (CORS). Valid values:

  • true: enables CORS. This is the default value.

  • false: disables CORS.

withCredentials

No

Boolean

Specifies whether to include the cookie in a CORS request. Valid values:

  • true: includes the cookie in a CORS request.

  • false: does not include the cookie in a CORS request. This is the default value.

hasAudio

No

Boolean

Specifies whether to include the audio in the video stream. Valid values:

  • true: Set this parameter to true only if you are sure that the video stream contains audio.

  • false: If you are not sure whether the video stream contains audio, set this parameter to false.

hasVideo

No

Boolean

Specifies whether to include the video in the video stream. Valid values:

  • true: Set this parameter to true only if you are sure that the video stream contains the video.

  • false: If you are not sure whether the video stream contains the video, set this parameter to false.

We recommend that you set this parameter to false.

duration

No

Number

The total duration of the video. Unit: milliseconds.

filesize

No

Number

The size of the video. Unit: bytes.

flvConfig

Parameter

Required

Type

Description

enableWorker

No

Boolean

Specifies whether to enable multithreading for decapsulating the video stream. Valid values:

  • true: enables multithreading for decapsulating the video stream.

  • false: disables multithreading for decapsulating the video stream. This is the default value.

enableStashBuffer

No

Boolean

Specifies whether to enable the I/O stash buffer. Valid values:

  • true: enables the I/O stash buffer. This is the default value.

  • false: disables the I/O stash buffer.

If you want to reduce the latency and the occurrence of stuttering upon poor network conditions in live streaming, set the parameter to false.

stashInitialSize

No

Number

The initial size of the I/O stash buffer. Default value: 384 KB.

lazyLoad

No

Boolean

Specifies whether to close the connection over HTTP for stream pulling when enough data is obtained for playback. Valid values:
  • true: closes the connection. This is the default value.

  • false: does not close the connection.

lazyLoadMaxDuration

No

Number

The video duration that can be loaded before stream pulling is stopped. Default value: 180. Unit: seconds.

lazyLoadRecoverDuration

No

Number

The duration between the time when stream pulling is stopped and the time when stream pulling is recovered. Default value: 30. Unit: seconds.

deferLoadAfterSourceOpen

No

Boolean

Specifies whether to load the video stream after the sourceopen event of the MediaSource object is triggered.

Note

If you use Chrome, a tab that is opened in the background may not trigger the sourceopen event. You must switch to this tab to trigger the sourceopen event.

autoCleanupSourceBuffer

No

Boolean

Specifies whether to enable auto cleanup for SourceBuffer. Valid values:

  • true: enables auto cleanup for SourceBuffer.

  • false: disables auto cleanup for SourceBuffer. This is the default value.

autoCleanupMaxBackwardDuration

No

Number

The maximum value of the backward buffer duration. If the value is exceeded, auto cleanup is performed. Default value: 180. Unit: seconds.

autoCleanupMinBackwardDuration

No

Number

The video duration to reserve for backward buffer. Default value: 120. Unit: seconds.

fixAudioTimestampGap

No

Boolean

Specifies whether to fill silent audio frames when audio and video signals are out of synchronization. Valid values:

  • true: fills silent audio frames. This is the default value.

  • false: does not fill silent audio frames.

accurateSeek

No

Boolean

Specifies whether to enable accurate frame seek. Valid values:
  • true: enables accurate frame seek.

  • false: disables accurate frame seek. This is the default value.

Note

  • Frames that can be accurately sought to are not limited to Instantaneous Decoding Refresh (IDR) frames. The speed of accurately seeking to non-IDR frames may be lower.

  • We recommend that you use FireFox, Safari, or Chrome 50 or later.

customSeekHandler

No

Object

The custom seek handler. Default value: undefined.

reuseRedirectedURL

No

Boolean

Specifies whether to reuse the redirected URL for subsequent seek or reconnection requests when the HTTP status code 301 or 302 is returned. Valid values:

  • true: reuses the redirected URL.

  • false: does not reuse the redirected URL.

referrerPolicy

No

String

The referrer policy applied when FetchStreamLoader is used. For more information, see Referrer Policy. Default value: no-referrer-when-downgrade.

headers

No

Object

The additional headers that you want to add to requests.

HTML5-related parameters

Parameter

Required

Type

Description

hls

No

Object

The configurations related to HTTP Live Streaming (HLS).

cacheEncryptionKeys

Yes

Boolean

Specifies whether to cache encryption keys. Valid values:

  • true: caches encryption keys.

  • false: does not cache encryption keys.

Note

If this parameter is set to false, the player requests the encryption key each time before TS segments are obtained.

overrideNative

No

Boolean

Specifies whether to use videojs-http-streaming (VHS) when the browser supports HLS. Valid values:

  • true: uses VHS when the browser supports HLS.

  • false: does not use VHS when the browser supports HLS.

Other common configurations

play

Feature: plays a video.

play() => Promise<undefined> | undefined

pause

Feature: pauses the playback.

pause() => Player

src

Feature: specifies the playback source.

If you do not set the parameter, the stream pulling feature is used.

src(source?: { src: string, type: string }) => string | undefined

reset

Feature: resets the player.

If the method is called, the reset method in Video.js is also called.

reset() => void

load

Feature: loads the playback source.

load() => void

currentTime

Feature: specifies the position from which the playback starts.

If you do not set the parameter, the current playback position is used.

currentTime(seconds?: number) => number

autoplay

Feature: specifies whether to enable autoplay.

You must set the parameter to be consistent with the autoplay option provided by Video.js. If you do not set the parameter, the value of the autoplay option is used.

autoplay(value: boolean | string) => void

paused

Feature: specifies whether to pause the playback.

paused() => boolean

on

Feature: enables a listener.

on(type: string, fn: Function) => Player

The following listeners are supported:

  • canplay: The listener is triggered when enough data is loaded for playback.

  • ended: The listener is triggered when the playback ends.

  • error: The listener is triggered when a playback error occurs.

  • flvError: The listener is triggered when an FLV video stream fails to be played.

  • loadeddata: The listener is triggered when the browser loads video frames.

  • play: The listener is triggered when the playback starts.

  • playing: The listener is triggered when the video stream is being played. If stuttering occurs due to reasons such as poor network conditions, the listener is repeatedly triggered.

off

Feature: disables a listener.

off(type: string, fn: Function) => Player