# Event Listeners Reference
ByteArk Player emits events on its player instance. You can subscribe to them to react to playback lifecycle changes.
Note
Because ByteArk Player is built on Video.js, all Video.js events are also available. See the Video.js Player API (opens new window) for the full reference.
# Usage
# player.on(type, fn)
Add an event listener that fires every time the subscribed event occurs.
Parameters
| Attribute | Description | Type |
|---|---|---|
| type | Event type to subscribe to | String |
| fn | Function called when the event fires | Function |
# player.one(type, fn)
Add an event listener that fires once when the subscribed event occurs.
Parameters
| Attribute | Description | Type |
|---|---|---|
| type | Event type to subscribe to | String |
| fn | Function called when the event fires | Function |
# player.off(type, fn)
Remove a listener previously added via player.on or player.one.
Parameters
| Attribute | Description | Type |
|---|---|---|
| type | Event type to unsubscribe from | String |
| fn | The listener function to remove | Function |
# Example
player.on('play', function() {
console.log('Playback started');
});
player.one('ready', function() {
console.log('Player is ready (fired once)');
});
1
2
3
4
5
6
7
2
3
4
5
6
7
# Lifecycle events
| Event | Description |
|---|---|
ready | Player is ready to use |
firstplay | The video starts playing for the first time |
play | Playback starts/resumes |
pause | Playback is paused |
ended | Playback ends |
# Buffer & seek events
| Event | Description |
|---|---|
seeking | Viewer is seeking |
waiting | Player is waiting for data (buffering) |
# Progress events
| Event | Description |
|---|---|
timeupdate | Current playback position changed |
ratechange | Playback rate changed |
# UI events
| Event | Description |
|---|---|
fullscreenchange | Enter or exit fullscreen mode |
volumechange | Volume changed |
enterpictureinpicture | Enter Picture-in-Picture mode |
leavepictureinpicture | Exit Picture-in-Picture mode |
# Error event
| Event | Description |
|---|---|
error | A player error occurred |