Browse Source

Merge pull request #1112 from wdssmq/for-pr

DIYgod 2 years ago
parent
commit
b16e54049b
3 changed files with 23 additions and 1 deletions
  1. 1 1
      demo/demo.js
  2. 0 0
      dist/DPlayer.min.js.map
  3. 22 0
      src/js/player.js

+ 1 - 1
demo/demo.js

@@ -247,7 +247,7 @@ function clearPlayers() {
 }
 }
 
 
 function switchDPlayer() {
 function switchDPlayer() {
-    if (dp2.option.danmaku.id !== '5rGf5Y2X55qu6Z2p') {
+    if (dp2.options.danmaku.id !== '5rGf5Y2X55qu6Z2p') {
         dp2.switchVideo({
         dp2.switchVideo({
             url: 'http://static.smartisanos.cn/common/video/t1-ui.mp4',
             url: 'http://static.smartisanos.cn/common/video/t1-ui.mp4',
             pic: 'http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg',
             pic: 'http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg',

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


+ 22 - 0
src/js/player.js

@@ -533,6 +533,7 @@ class DPlayer {
         if (this.qualityIndex === index || this.switchingQuality) {
         if (this.qualityIndex === index || this.switchingQuality) {
             return;
             return;
         } else {
         } else {
+            this.prevIndex = this.qualityIndex;
             this.qualityIndex = index;
             this.qualityIndex = index;
         }
         }
         this.switchingQuality = true;
         this.switchingQuality = true;
@@ -576,6 +577,27 @@ class DPlayer {
                 this.events.trigger('quality_end');
                 this.events.trigger('quality_end');
             }
             }
         });
         });
+
+        this.on('error', () => {
+            if (!this.video.error) {
+                return;
+            }
+            if (this.prevVideo) {
+                this.template.videoWrap.removeChild(this.video);
+                this.video = this.prevVideo;
+                if (!paused) {
+                    this.video.play();
+                }
+                this.qualityIndex = this.prevIndex;
+                this.quality = this.options.video.quality[this.qualityIndex];
+                this.noticeTime = setTimeout(() => {
+                    this.template.notice.style.opacity = 0;
+                    this.events.trigger('notice_hide');
+                }, 3000);
+                this.prevVideo = null;
+                this.switchingQuality = false;
+            }
+        });
     }
     }
 
 
     notice(text, time = 2000, opacity = 0.8) {
     notice(text, time = 2000, opacity = 0.8) {

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