Live Barrage
Updated: 2022-05-23 19:00:06
POLYV Live Barrage API
1. Embedding the Player
<script src="http://live.polyv.net/assets/js/liveplayer.js"></script>
<div id='player'></div>
<script type="text/javascript">
var player = polyvObject('#player').createDanMuPlayer({
'width':'100%',
'height':'250',
'userId':'e3wx706i3v',
'channelId':'99863',
'pic':'null',
'userName':'null',
'hash':'da4c443430ad099d1694a9c21b59c5af'
/*'hideInput':'on',*/
/* 'isBarrage':'off',*/
/*'hideControls':'2'*/
});
</script>
2. Parameter Settings
| Parameter | Value Range | Description | Required | Notes |
|---|---|---|---|---|
| width | Percentage or pixel value | Player width | Yes | ----- |
| height | Percentage or pixel value | Player height | Yes | ----- |
| userId | String | Customer UID | Yes | ----- |
| channelId | String | Customer VID | Yes | ----- |
| pic | String | Avatar URL | Yes | ----- |
| userName | String | Nickname | Yes | ----- |
| hash | String | Hash value according to rules | Yes | ----- |
| hideInput | on/off | Whether to hide the barrage input button, default off | ----- | ----- |
| isBarrage | on/off | Whether to display barrage initially, default on | ----- | ----- |
| hideControls | 0~2 | Display of mobile control bar, default 2. 0: Neither native nor polyv skin displayed, 1: Native skin displayed, 2: Polyv skin displayed | ----- | ----- |
Ps: The hash value is the MD5 of the string userId + username + pic + "polyvlive". If the calculation is incorrect, the player page cannot be opened normally.
As shown above: The string for MD5 is: e3wx706i3vnullnullpolyvlive The MD5 value is: da4c443430ad099d1694a9c21b59c5af The hash parameter value should be: da4c443430ad099d1694a9c21b59c5af
3. API Calls
| Method Name | Parameters | Description | Notes |
|---|---|---|---|
| j2s_showBarrage | ----- | Show barrage | ----- |
| j2s_hideBarrage | ----- | Hide barrage | ----- |
| j2s_addBarrageMessage | See ps example below | Send barrage | ----- |
Ps: On mobile, font size, color, and display effects cannot be set. Fixed at font size 14, white text with black border, scrolling effect.
Barrage sending, parameter is a standard JSON format string. Example of the _str string parameter:
'[{
"msg":"1463bf66ce3",
"fontSize":"24",
"fontColor":"0xCCCC00",
"fontMode":"roll"
}]'
| Parameter | Value | Meaning | Required |
|---|---|---|---|
| msg | String | Barrage message | Yes |
| fontSize | String | Font size | Yes |
| fontColor | String | Font color | Yes |
| fontMode | String | Font display effect | Yes |
