use DPlayer-node v2

This commit is contained in:
DIYgod 2018-01-12 00:35:59 +08:00
parent ec160d1587
commit 6f61076345
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
6 changed files with 25 additions and 19 deletions

View File

@ -121,15 +121,14 @@ function initPlayers () {
// });
// // dp4
window.dp4 = new DPlayer({
container: document.getElementById('dplayer4'),
preload: 'none',
autoplay: true,
video: {
url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
type: 'hls'
}
});
// window.dp4 = new DPlayer({
// container: document.getElementById('dplayer4'),
// preload: 'none',
// video: {
// url: 'https://moeplayer.b0.upaiyun.com/dplayer/hls/hikarunara.m3u8',
// type: 'hls'
// }
// });
// // dp5
// window.dp5 = new DPlayer({

2
dist/DPlayer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.18.1",
"version": "1.19.0",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"style": "dist/DPlayer.min.css",

View File

@ -1,7 +1,7 @@
/*
* xhr.status ---> fail
* response.code === 1 ---> success
* response.code !== 1 ---> error
* response.code === 0 ---> success
* response.code !== 0 ---> error
* */
const SendXMLHttpRequest = (url, data, success, error, fail) => {
@ -12,7 +12,7 @@ const SendXMLHttpRequest = (url, data, success, error, fail) => {
if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
const response = JSON.parse(xhr.responseText);
if (response.code !== 1) {
if (response.code !== 0) {
return error(xhr, response);
}

View File

@ -21,10 +21,10 @@ class Danmaku {
load () {
let apiurl;
if (this.options.api.maximum) {
apiurl = `${this.options.api.address}?id=${this.options.api.id}&max=${this.options.api.maximum}`;
apiurl = `${this.options.api.address}v2/?id=${this.options.api.id}&max=${this.options.api.maximum}`;
}
else {
apiurl = `${this.options.api.address}?id=${this.options.api.id}`;
apiurl = `${this.options.api.address}v2/?id=${this.options.api.id}`;
}
const endpoints = (this.options.api.addition || []).slice(0);
endpoints.push(apiurl);
@ -67,7 +67,14 @@ class Danmaku {
results[i] = [];
}
else {
results[i] = data;
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 (readCount === endpoints.length) {
return callback(results);
@ -89,7 +96,7 @@ class Danmaku {
color: dan.color,
type: dan.type
};
this.options.apiBackend.send(this.options.api.address, danmakuData, callback);
this.options.apiBackend.send(this.options.api.address + 'v2/', danmakuData, callback);
this.dan.splice(this.danIndex, 0, danmakuData);
this.danIndex++;