use DPlayer-node v2
This commit is contained in:
parent
ec160d1587
commit
6f61076345
17
demo/demo.js
17
demo/demo.js
|
|
@ -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({
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue