Setting Up Live Player Danmaku
Updated: 2021-07-13 11:31:09
1. Embedding the Live Player
Embed the following code in your page. It is visible in the [Player Embed] section under [My Live Streams] in the POLYV Live Console.
<script src="https://player.polyv.net/livescript/liveplayer.js"></script>
<div id='player'></div>
<script type="text/javascript">
var player = polyvObject('#player').livePlayer({
'width':'498',
'height':'409',
'flashvars':{"is_barrage":"on"},
'uid':'e3wx706i3v',
'vid':'99853'
});
</script>
2. API
Example page:
http://playertest.polyv.net/player2/test/demo/Livedanmu.html
function j2s_setBarrage( ){
return true;
}
Danmaku feature toggle. Must return true. The player checks this parameter to determine whether to enable the danmaku feature.
function j2s_showBarrage( ){
if( player!=undefined&&player.j2s_showBarrage!=undefined ){
player.j2s_showBarrage( );
}
}
Show danmaku. Default is visible.
function j2s_hideBarrage( ){
if( player!=undefined && player.j2s_hideBarrage!=undefined ){
player.j2s_hideBarrage( );
}
}
Hide danmaku.
function j2s_addBarrageMessage( _str ){
if( player!=undefined && player.j2s_addBarrageMessage!=null){
player.j2s_addBarrageMessage(_str );
}
}
Send danmaku. The parameter is a standard JSON format string.
'[{
"msg":"1463bf66ce3",
"fontSize":"24",
"fontColor":"0xCCCC00",
"fontMode":"roll"
}]'
_str string parameter example:
| Parameter | Value | Description | Required |
|---|---|---|---|
| msg | string | Danmaku message to send | ✔️ |
| fontSize | string | Danmaku font size | ✔️ |
| fontColor | string | Danmaku font color | ✔️ |
| fontMode | string | Danmaku entry effect: roll (horizontal entry from the right) |
✔️ |
