Polyv Help Center

Help Center

Properties and Interface Description

Updated: 2025-10-10 12:02:04

Player Properties

Pass all parameters as an object to the player. The configurable properties include:

Name Type Required Description
vid string Yes The unique ID of the audio/video uploaded to the Polyv platform.
viewerInfo object Optional Custom viewer information. When set, the viewer information will be attached to the viewing behavior logs reported by the player. See Viewer Information Settings and Statistics.
wrap string Optional The CSS selector for the container to load the player into.
skin string Optional Player skin (white / grey). If using a custom player skin, this parameter is not required.
autoPlay boolean Optional Whether to autoplay. Note: Most browsers currently restrict autoplay, so this parameter may be ineffective.
loop boolean Optional Whether to loop playback.
volume number Optional Volume (range 0~1).
speed number | boolean Optional If a number is passed, it sets the default playback speed. If a boolean, setting it to false hides the speed options panel on the player interface.
speedOptions array Optional Array of speed options. Default value: [0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0]. If speed is a number and is not present in the speedOptions array, it will be automatically added to the array.
startTime number Optional Start playback from this second. Must be less than the video duration.
playsafe function | string Optional Authorization credential required for playing encrypted audio/video on PC. Only needed for playing encrypted audio/video on PC; can be ignored for non-encrypted content. See: Playing Encrypted Video.
playsafeUrl string Optional The API endpoint URL to obtain the authorization credential for playing encrypted audio/video on PC. Choose either this or the playsafe parameter.
sign string Optional Signature required for playing encrypted audio/video on mobile. Can be ignored for non-encrypted content. See: Playing Encrypted Video.
ts string Optional Timestamp required for playing encrypted audio/video on mobile.

Static Properties

Accessible via PlvAudioPlayer[key].

Name Type Description
EventType object Summary of callback events.

Instance Properties

Each player instance has the following properties:

Name Type Description
audio object The native audio object.
currentTime number Current playback position, in seconds.
duration number Current audio duration, in seconds.
paused boolean Whether the player is currently paused.

Player API

APIs must be called after the player initialization is complete, for example:

plvAudioPlayer.on('ready', function() {
  console.info('播放器初始化完毕');
  plvAudioPlayer.seek(100); // seek到第100秒
});
```

The player API list is as follows:

| Name               | Parameter Type  | Description                                                  |
| ------------------ | --------------- | ------------------------------------------------------------ |
| play               | /               | Start playback.                                              |
| pause              | /               | Pause playback.                                              |
| (async) changeVid  | (String\|Object)| Switch media files. Can pass a `vid` string, or an object containing `playsafe`, `sign`, `ts`, and `vid` properties. |
| seek               | Number          | Jump to a specified position for playback. Parameter unit: seconds. |
| setLoop            | Boolean         | Whether to loop playback.                                    |
| setSpeed           | Number          | Set playback speed. Parameter range: (0, 16]. Invalid values will be set to 1. |
| setVolume          | Number          | Set volume. Parameter range: [0, 1]. Invalid values will be set to 1. |
| stop               | /               | Stop playback.                                               |
| (async) updateParam| /               | Update player parameters. Audio will stop playing and reload. Supports the player property parameters listed in this document. |
| destroy            | /               | Destroy the current player instance.                         |

## Player Events

The player provides some common event callbacks. Usage example:

```js
plvAudioPlayer.on('ready', function() {
  console.info('ready');
});
```

The event list is as follows:

| Name        | Description                                                  |
| ----------- | ------------------------------------------------------------ |
| ready       | Fired when the player initialization is complete. Player methods can only be called after this event. The callback returns a `data` object containing audio information. Audio-related details can be obtained via `data.audioInfo`. |
| loadstart   | Fired when the media starts loading.                         |
| play        | Fired when media playback starts.                            |
| playing     | Fired during playback, may trigger multiple times.           |
| pause       | Fired when playback is paused.                               |
| seeking     | Fired when a seek operation starts.                          |
| seeked      | Fired when a seek operation completes.                       |
| ratechange  | Fired when the playback rate changes.                        |
| timeupdate  | Fired when the current playback time (`currentTime` property) changes. |
| waiting     | Fired when a pending operation (e.g., play) is delayed due to waiting for another operation (e.g., seek or load). |
| ended       | Fired when playback ends.                                    |
| stop        | Fired after the `stop` method completes.                     |
| hlsError    | Fired when an error occurs while playing an HLS file.        |
| serverError | Fired when a playback error occurs. The callback returns a `data` object containing error information. The error code can be obtained via `data.code`. |
联系客服,在线咨询