|
@@ -13,6 +13,7 @@ import User from './user';
|
|
import Subtitle from './subtitle';
|
|
import Subtitle from './subtitle';
|
|
|
|
|
|
let index = 0;
|
|
let index = 0;
|
|
|
|
+const instances = [];
|
|
|
|
|
|
class DPlayer {
|
|
class DPlayer {
|
|
|
|
|
|
@@ -788,6 +789,7 @@ class DPlayer {
|
|
this.initVideo(this.video, this.quality && this.quality.type || this.options.video.type);
|
|
this.initVideo(this.video, this.quality && this.quality.type || this.options.video.type);
|
|
|
|
|
|
index++;
|
|
index++;
|
|
|
|
+ instances.push(this);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -832,6 +834,13 @@ class DPlayer {
|
|
if (this.danmaku) {
|
|
if (this.danmaku) {
|
|
this.danmaku.play();
|
|
this.danmaku.play();
|
|
}
|
|
}
|
|
|
|
+ if (this.options.mutex) {
|
|
|
|
+ for (let i = 0; i < instances.length; i++) {
|
|
|
|
+ if (this !== instances[i]) {
|
|
|
|
+ instances[i].pause();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1167,6 +1176,7 @@ class DPlayer {
|
|
}
|
|
}
|
|
|
|
|
|
destroy () {
|
|
destroy () {
|
|
|
|
+ instances.splice(instances.indexOf(this), 1);
|
|
this.pause();
|
|
this.pause();
|
|
clearTimeout(this.hideTime);
|
|
clearTimeout(this.hideTime);
|
|
this.video.src = '';
|
|
this.video.src = '';
|