Danmaku
Updated: 2023-04-24 09:53:29
Feature Overview
The POLYV player includes a danmaku feature that enhances interactivity while watching videos.
Feature API
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| danmuEnable | boolean | false |
Whether to enable the danmaku feature |
| showDanmu | boolean | true |
Initial display state of danmaku when enabled. If false, danmaku is not shown initially. |
| banDanmuBtn | boolean | false |
When true, the danmaku button is hidden |
Parameter configuration example
var player = polyvLivePlayer({
wrap: '#player',
width: 800,
height: 533,
uid:'uid',
vid:'vid',
danmuEnable: true,
});
Methods
| Method | Parameters | Return Value | Description |
|---|---|---|---|
| j2s_addBarrageMessage | Object | / | Danmaku display text, supports embedded images. See below for details. |
Method details
j2s_addBarrageMessage
| Parameter | Type | Values | Default | Description | Required |
|---|---|---|---|---|---|
| msg | string | / | / | Danmaku content. Images must be enclosed in [[...]] | Yes |
| fontSize | number | / | 30 | Font size | No |
| fontColor | string | Hexadecimal color value | 0x000000 | Font color | No |
| fontMode | string | roll | top | bottom | roll | Display mode: roll - scrolls from right to left across the screen top - fixed at the top bottom - fixed at the bottom |
No |
Method call example
j2s_addBarrageMessage
// 文本弹幕
const danmuData = {
msg: '这是文本弹幕数据',
fontSize: 30,
fontMode: 'roll',
fontColor: '0x000000',
};
player.j2s_addBarrageMessage(danmuData);
// 文本内嵌图片弹幕,需要将图片地址用双中括号包裹使用
const danmuData = {
msg: '这是图片[[http://www.mywebsite.com/1.jpg]]弹幕数据',
fontSize: 30,
fontMode: 'roll',
fontColor: '0x000000',
};
player.j2s_addBarrageMessage(danmuData);
