The H5Player implements hook functions during playing based on webpack/tapable. This provides the access party with the feasibility of intervening during playing.
Name | Trigger Event | Callback Parameters |
---|---|---|
afterPlayerInit | Triggered after player initialization. | (player, playConfig) The player instance and the play configuration parameters |
onChannelRender | Triggered by AI parameter callback for channel rendering. | (param: Frame['param'], renderer: PlayRender) The frame data AI parameters, rendering DOM node |
afterLoaded | Triggered when the stream data connection is successfully acquired. | (player, eventData) The player instance and the returned link data |
afterReady | Triggered by the play-ready event for user-triggered play. | (player, eventData) The player instance and the returned play status data |
beforePlay | Triggered when the user calls to play. | (player, eventData) The player instance and the play data delivered |
afterPlay | Triggered when the renderer begins to play, and the state machine changes to Playing status. | (player, eventData) The player instance and the play data delivered |
beforePause | Triggered when the user calls to pause. | (player, eventData) The player instance and the play data delivered |
afterPause | Triggered when the renderer pauses playing, and the state machine changes to Paused status. | (player, eventData) The player instance and the callback pause data |
beforeStop | Triggered when the user calls to stop. | (player, eventData) The player instance and the play data delivered |
afterStop | Triggered when the renderer stops playing, and the state machine changes to Stopped status. | (player, eventData) The player instance and the callback stop data |
beforeSeek | Triggered when the user calls to seek, entering Seeking status. | (player, eventData) The player instance and the play data delivered |
afterSeek | Triggered when the seek is successful, and the state machine changes to Playing status. | (player, eventData) The player instance and the callback seek data |
beforeDestroy | Triggered when the user calls to destroy. | (player, eventData) The player instance and the destroy data delivered |
onError | Error callback event | (errorData, player) The standard errorData and the player instance |
onPlayEnded | Triggered when the auto-play ends. | (player, eventData) The player instance and the ended channel information data |
onLoading | Used for callback of loading percentage and network speed information, applicable to both live view and playback. | (list, done) The player channel status information and the flag indicating whether loading is complete |
loadingTimeout | Used to determine the buffer timeout (20 s). The timeout duration is the same as the seek timeout. | (list) |
startReconnect | The hook triggered when starting to reconnect after a disconnection. | (player, eventData) The player instance and the reconnection information |
reconnectSuccess | The hook triggered upon successful reconnection after a disconnection. | (player, eventData) The player instance and the reconnection information |
onVideoPlaceholder | Triggered when the playback channel status changes. It needs to be distinguished from the player status. The playback status refers to whether the channel is playing a stream or is idle. The placeholder plugin can be used to customize the mask when there is no video. | (statusList) |
onTimeChange | Actively pushes time during playback. The push frequency can be configured in config. The default value is 500ms. For smooth timeline movement in the business layer, the frequency can be set lower, especially for small files in server playback. | (params: [data]) The time information |
onMediaInfo | Media information callback, currently mainly including timeList (business layer needs to perceive duration information under network flow conditions) | (player, eventData) The player instance and media info |
onMessage | Prompt information callback event | (code, message) Reminder information |
onFramePlayNoData | Frame-by-frame no data event | (player, type) The player instance and frame type (0: next frame, 1: previous frame) |
onStreamTypeChange | Stream switching event | (player, eventData) Player instance, event data |
onInputAudioDevicesChange | Audio input device change event | (eventData, player) Event data, intercom instance |
Description
It is triggered after the player is initialized, and is currently only effective for live view instances.
Example
Note: The player in the example refers to the player instance.
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
config | The parameters for rendering |
Description
It is triggered after the player obtains the media stream address. At this point, the video has not started playing nor has the intercom been listened. It is effective for live-view players, playback players, and intercom listening instances.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The returned link data |
Description
It is triggered when the player is ready to start playing, applicable to both live view and playback.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The returned play status data |
Description
It is triggered before the player receives the play notification. For live view, the play starts automatically when the load is called, so it only takes effect for playback.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The play data delivered |
Description
It is triggered after the player receives the play notification, effective for playback.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The play data delivered |
Description
It is triggered before the player receives the pause notification, effective for playback.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The play data delivered |
Description
It is triggered after the player receives the pause notification, effective for playback.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The play data delivered |
Description
Callback before the video stops, effective for playback.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
eventData | The play data delivered |
Description
It is triggered after the player stops.
Example
Callback Parameters
The timeData parameter is of Object type and is only applicable for intercom listening. The structure is as follows:
Parameter | Description |
---|---|
startTime | The start time, client UTC timestamp (in milliseconds). If not started, this value is null. |
endTime | The end time, client UTC timestamp (in milliseconds). |
duration | The play duration (in milliseconds). If not started, this value is null. |
Description
It is triggered when the user calls to seek, entering a Seeking status. This is only effective for playback.
Example
Callback Parameters
Parameter | Type | Description |
---|---|---|
player | The player instance | |
eventData | The play data delivered |
Description
It is triggered after the seek operation is completed. This is only effective for playback.
Example
Callback Parameters
Parameter | Type | Description |
---|---|---|
timeData | Object | The time data. Refer to afterStop. |
Note: In case of a seek failure, the onError callback will be used.
Description
Callback before the video is destroyed.
Example
Callback Parameters
Parameter | Description |
---|---|
player | The player instance |
preventExecution | A blocking function to prevent further execution of destroy |
Description
It is triggered when playback is completed.
Example
Description
The error callback that listens to various errors occurring during playback or live view.
Example
player.hooks.onError.tap('An error occurred', callback(errorInfo, player?));
Callback Parameters
Name | Type | Description |
---|---|---|
errorInfo | Object | Additional information |
player | class | The player instance |
For details, refer to error-info
Description
The hook triggered when starting to reconnect after a disconnection in live view.
Example
Description
The hook triggered upon successful reconnection after a disconnection in live view.
Example
Description
Triggered when the playback channel status changes. It needs to be distinguished from the player status. The playback status refers to whether the channel is playing a stream or is idle. The placeholder plugin can be used to customize the mask when there is no video.
Example
Callback Parameters
Parameter | Data Type | Description | |
---|---|---|---|
playersStatus | Object[] | The collection of channel play status changes | |
playerStatus:Object | devId | String | Device ID |
channel | Number | Channel number | |
status | String | The changed play status | |
next | Function | The callback function for placeholder |
Description
Used for callback of loading percentage and network speed information, applicable to both live view and playback.
Note: In live view mode, you cannot use the done parameter to determine if loading is finished. You need to check if the channel's percent equals 100 to cancel loading for a single channel.
Example
Callback Parameters
Parameter | Data Type | Description | |
---|---|---|---|
loadingList | Object[] | List of device channel information during loading | |
devId | string | Device number | |
channel | number | Channel number | |
percent | number | The loading progress percentage, which is ranging from 0 to 100. | |
network | number | The network speed information (in KB/s). | |
done | boolean | Indicates whether the loading is completed. |
Description
Used to determine the buffer timeout. The timeout duration follows the general configuration, with a default of 20s.
Example
Callback Parameters
Parameter | Data Type | Description | |
---|---|---|---|
deviceInfo | Object[] | The list of device channels | |
deviceInfo:Object | devId | String | Device ID |
channel | Number | Channel number |
Description
Actively pushes time during playback. The push frequency can be configured in config. The default value is 500ms.
For smooth timeline movement in the business layer, the frequency can be set lower, especially for small files in server playback.
Example
Callback Parameters
Parameter | Data Type | Description | |
---|---|---|---|
timeData | Object | ||
dateTime | String | The formatted time string according to the provided timezone configuration, e.g., "2022-12-28 16:17:34". The format can be configured in the global configuration Config. The default value is "YYYY-MM-DD HH:mm:ss". | |
utc | Number | The UTC time in seconds (int). | |
ms | Number | The milliseconds after UTC seconds, which is ranging from 0 to 999. |
Description
It provides the device information or AI information of the currently rendered frame in the player.
Example
Callback Parameters
Parameter | Data Type | Description |
---|---|---|
frame | object | The frame data carrying AI or device information. |
chanPlayers | object | The channel player currently rendering the frame. |
Description
Media information feedback
Example
Callback Parameters
Parameter | Data Type | Description |
---|---|---|
player | class | Player instance |
eventData | object | The channel player currently rendering the data frame |
|-name | string | Data type name: such as timeList |
|-data | object | Data type information |
Description
Prompt information callback
Example
Callback Parameters
Parameter | Data Type | Description |
---|---|---|
code | string | Prompt error code |
message | string | Prompt description |
Description
Frame-by-frame no data callback
Example
Callback Parameters
Parameter | Data Type | Description |
---|---|---|
player | class | The player instance |
type | number | Frame type. 0-next frame, 1-previous frame |
options | object | Other parameters. Refer to the following table |
options
参数 | 说明 |
---|---|
isFirst | Whether it's the first frame |
isLast | Whether it's the last frame |
Description
Player state change callback
Example
Callback Parameters
Parameter | Type | Description |
---|---|---|
player | class | Player instance |
stateInfo | object | Refer to the stateInfo type definition below |
state | string | Refer to Player States |
stateInfo
Description
Player stream switching callback
Example
Callback Parameters
Parameter | Data Type | Description |
---|---|---|
player | class | Player instance |
eventData | object | Refer to TEventData type below |
TEventData
Description
Player audio input devices change callback
Example
Callback Parameters
Parameter | Data Type | Description |
---|---|---|
eventData | object | Refer to TEventData type below |
player | class | Player instance |
TEventData