Danmaku
Updated: 2021-07-13 11:31:09
Feature Overview
The POLYV player includes a danmaku (bullet screen) feature, which enhances interactivity while watching videos.
Feature API
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| danmuEnable | boolean | false |
Whether to enable the danmaku feature |
| showDanmu | boolean | true |
Danmaku status; when false, it is initially off |
| banDanmuBtn | boolean | false |
When true, the danmaku button is not displayed |
Parameter configuration example
var player = polyvLivePlayer({
wrap: '#player',
width: 800,
height: 533,
uid:'uid',
vid:'vid',
danmuEnable: true,
});
Methods
| Method Name | Parameter | Return Value | Description |
|---|---|---|---|
| j2s_addBarrageMessage | string | / | Supports text and images; images must be enclosed in [[...]] |
| setBarrageStatus | boolean | / | Dynamically show or hide the danmaku module |
Method call example
const str = 'ajskd[[http://www.mywebsite.com/1.jpg]]'
const danmuData = `[{"msg":"${str}","fontSize":24,"fontColor":"0xffffff","fontMode":"roll"}]`;
player.j2s_addBarrageMessage(danmuData);
player.setBarrageStatus(false);
Method details
j2s_addBarrageMessage
| Parameter | Value | Default | Description | Required |
|---|---|---|---|---|
| msg | / | / | Danmaku content; images must be enclosed in [[...]] | ✔️ |
| fontSize | 12~ | 30 | Font size | ✔️ |
| fontColor | Hexadecimal color value | 0x000000 | Font color | ✔️ |
| fontMode | roll | roll | Display mode | ✔️ |
| fontArea | top/bottom | / | Display area | |
| fontAreaPercent | / | 25% | Display area percentage |
