Sfoglia il codice sorgente

use DPlayer-node v2

DIYgod 7 anni fa
parent
commit
6f61076345
6 ha cambiato i file con 23 aggiunte e 17 eliminazioni
  1. 8 9
      demo/demo.js
  2. 0 0
      dist/DPlayer.min.js
  3. 0 0
      dist/DPlayer.min.js.map
  4. 1 1
      package.json
  5. 3 3
      src/js/api.js
  6. 11 4
      src/js/danmaku.js

+ 8 - 9
demo/demo.js

@@ -121,15 +121,14 @@ function initPlayers () {
     // });
     // });
 
 
     // // dp4
     // // 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
     // // dp5
     // window.dp5 = new DPlayer({
     // window.dp5 = new DPlayer({

File diff suppressed because it is too large
+ 0 - 0
dist/DPlayer.min.js


File diff suppressed because it is too large
+ 0 - 0
dist/DPlayer.min.js.map


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "dplayer",
   "name": "dplayer",
-  "version": "1.18.1",
+  "version": "1.19.0",
   "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",

+ 3 - 3
src/js/api.js

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

+ 11 - 4
src/js/danmaku.js

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

Some files were not shown because too many files changed in this diff