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:
Note You can also set the option to |
muted | No | Boolean | Specifies whether to enable muting. Valid values:
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:
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 |
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 |
preload | No | String | Specifies whether to preload the video. Valid values:
|
loop | No | Boolean | Specifies whether to enable loop playback. Valid values:
|
techOrder | Yes | Array | The order in which Video.js techs are preferred. In this example, set this option to |
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:
|
cors | No | Boolean | Specifies whether to enable cross-origin resource sharing (CORS). Valid values:
|
withCredentials | No | Boolean | Specifies whether to include the cookie in a CORS request. Valid values:
|
hasAudio | No | Boolean | Specifies whether to include the audio in the video stream. Valid values:
|
hasVideo | No | Boolean | Specifies whether to include the video in the video stream. Valid values:
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:
|
enableStashBuffer | No | Boolean | Specifies whether to enable the I/O stash buffer. Valid values:
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:
|
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:
|
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:
|
accurateSeek | No | Boolean | Specifies whether to enable accurate frame seek. Valid values:
Note
|
customSeekHandler | No | Object | The custom seek handler. Default value: |
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:
|
referrerPolicy | No | String | The referrer policy applied when FetchStreamLoader is used. For more information, see Referrer Policy. Default value: |
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:
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:
|
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