mirror of
https://github.com/DIYgod/DPlayer
synced 2024-11-22 18:56:54 +00:00
fix error in reading empty danmaku list
This commit is contained in:
parent
6f61076345
commit
6524114f05
40
demo/demo.js
40
demo/demo.js
@ -149,26 +149,26 @@ function initPlayers () {
|
||||
// }
|
||||
// });
|
||||
|
||||
// window.dp6 = new DPlayer({
|
||||
// container: document.getElementById('dplayer6'),
|
||||
// preload: 'none',
|
||||
// live: true,
|
||||
// danmaku: true,
|
||||
// apiBackend: {
|
||||
// read: function (endpoint, callback) {
|
||||
// console.log('假装 WebSocket 连接成功');
|
||||
// callback();
|
||||
// },
|
||||
// send: function (endpoint, danmakuData, callback) {
|
||||
// console.log('假装通过 WebSocket 发送数据', danmakuData);
|
||||
// callback();
|
||||
// }
|
||||
// },
|
||||
// video: {
|
||||
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
||||
// type: 'hls'
|
||||
// }
|
||||
// });
|
||||
window.dp6 = new DPlayer({
|
||||
container: document.getElementById('dplayer6'),
|
||||
preload: 'none',
|
||||
live: true,
|
||||
danmaku: true,
|
||||
apiBackend: {
|
||||
read: function (endpoint, callback) {
|
||||
console.log('假装 WebSocket 连接成功');
|
||||
callback();
|
||||
},
|
||||
send: function (endpoint, danmakuData, callback) {
|
||||
console.log('假装通过 WebSocket 发送数据', danmakuData);
|
||||
callback();
|
||||
}
|
||||
},
|
||||
video: {
|
||||
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
||||
type: 'hls'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearPlayers () {
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
<h2 id="live">Live</h2>
|
||||
<div class="example">
|
||||
<button class="btn" onclick="drawDanmaku()">假装收到 WebSocket 弹幕</button>
|
||||
<button class="btn" onclick="dp6.danmaku.draw({text: '假装收到 WebSocket 弹幕', color: '#fff', type: 'right'})">假装收到 WebSocket 弹幕</button>
|
||||
<div id="dplayer6"></div>
|
||||
</div>
|
||||
|
||||
|
2
dist/DPlayer.min.js
vendored
2
dist/DPlayer.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/DPlayer.min.js.map
vendored
2
dist/DPlayer.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dplayer",
|
||||
"version": "1.19.0",
|
||||
"version": "1.19.1",
|
||||
"description": "Wow, such a lovely HTML5 danmaku video player",
|
||||
"main": "dist/DPlayer.min.js",
|
||||
"style": "dist/DPlayer.min.css",
|
||||
|
@ -68,13 +68,18 @@ class Danmaku {
|
||||
}
|
||||
else {
|
||||
const typeMap = ['right', 'top', 'bottom'];
|
||||
results[i] = data.map((item) => ({
|
||||
time: item[0],
|
||||
type: typeMap[item[1]],
|
||||
color: item[2],
|
||||
author: item[3],
|
||||
text: item[4]
|
||||
}));
|
||||
if (data) {
|
||||
results[i] = data.map((item) => ({
|
||||
time: item[0],
|
||||
type: typeMap[item[1]],
|
||||
color: item[2],
|
||||
author: item[3],
|
||||
text: item[4]
|
||||
}));
|
||||
}
|
||||
else {
|
||||
results[i] = [];
|
||||
}
|
||||
}
|
||||
if (readCount === endpoints.length) {
|
||||
return callback(results);
|
||||
|
Loading…
Reference in New Issue
Block a user