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({
|
window.dp6 = new DPlayer({
|
||||||
// container: document.getElementById('dplayer6'),
|
container: document.getElementById('dplayer6'),
|
||||||
// preload: 'none',
|
preload: 'none',
|
||||||
// live: true,
|
live: true,
|
||||||
// danmaku: true,
|
danmaku: true,
|
||||||
// apiBackend: {
|
apiBackend: {
|
||||||
// read: function (endpoint, callback) {
|
read: function (endpoint, callback) {
|
||||||
// console.log('假装 WebSocket 连接成功');
|
console.log('假装 WebSocket 连接成功');
|
||||||
// callback();
|
callback();
|
||||||
// },
|
},
|
||||||
// send: function (endpoint, danmakuData, callback) {
|
send: function (endpoint, danmakuData, callback) {
|
||||||
// console.log('假装通过 WebSocket 发送数据', danmakuData);
|
console.log('假装通过 WebSocket 发送数据', danmakuData);
|
||||||
// callback();
|
callback();
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// video: {
|
video: {
|
||||||
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
|
||||||
// type: 'hls'
|
type: 'hls'
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearPlayers () {
|
function clearPlayers () {
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
<h2 id="live">Live</h2>
|
<h2 id="live">Live</h2>
|
||||||
<div class="example">
|
<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 id="dplayer6"></div>
|
||||||
</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",
|
"name": "dplayer",
|
||||||
"version": "1.19.0",
|
"version": "1.19.1",
|
||||||
"description": "Wow, such a lovely HTML5 danmaku video player",
|
"description": "Wow, such a lovely HTML5 danmaku video player",
|
||||||
"main": "dist/DPlayer.min.js",
|
"main": "dist/DPlayer.min.js",
|
||||||
"style": "dist/DPlayer.min.css",
|
"style": "dist/DPlayer.min.css",
|
||||||
|
@ -68,13 +68,18 @@ class Danmaku {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const typeMap = ['right', 'top', 'bottom'];
|
const typeMap = ['right', 'top', 'bottom'];
|
||||||
results[i] = data.map((item) => ({
|
if (data) {
|
||||||
time: item[0],
|
results[i] = data.map((item) => ({
|
||||||
type: typeMap[item[1]],
|
time: item[0],
|
||||||
color: item[2],
|
type: typeMap[item[1]],
|
||||||
author: item[3],
|
color: item[2],
|
||||||
text: item[4]
|
author: item[3],
|
||||||
}));
|
text: item[4]
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
results[i] = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (readCount === endpoints.length) {
|
if (readCount === endpoints.length) {
|
||||||
return callback(results);
|
return callback(results);
|
||||||
|
Loading…
Reference in New Issue
Block a user