|
@@ -1,11 +1,11 @@
|
|
class Video {
|
|
class Video {
|
|
- constructor (videos, duration) {
|
|
|
|
|
|
+ constructor (videos, duration = 0) {
|
|
this.videos = videos;
|
|
this.videos = videos;
|
|
this.multi = this.videos.length > 1;
|
|
this.multi = this.videos.length > 1;
|
|
this.index = 0;
|
|
this.index = 0;
|
|
this.current = this.videos[this.index];
|
|
this.current = this.videos[this.index];
|
|
|
|
|
|
- this.duration = duration || 0;
|
|
|
|
|
|
+ this.duration = duration;
|
|
this.durationArr = [];
|
|
this.durationArr = [];
|
|
this.eventAll = [];
|
|
this.eventAll = [];
|
|
this.eventCurrent = [];
|
|
this.eventCurrent = [];
|
|
@@ -44,18 +44,11 @@ class Video {
|
|
// bind event
|
|
// bind event
|
|
on (type, event, callback) {
|
|
on (type, event, callback) {
|
|
if (typeof callback === 'function') {
|
|
if (typeof callback === 'function') {
|
|
- if (type === 'all') {
|
|
|
|
- if (!this.eventAll[event]) {
|
|
|
|
- this.eventAll[event] = [];
|
|
|
|
- }
|
|
|
|
- this.eventAll[event].push(callback);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- if (!this.eventCurrent[event]) {
|
|
|
|
- this.eventCurrent[event] = [];
|
|
|
|
- }
|
|
|
|
- this.eventCurrent[event].push(callback);
|
|
|
|
|
|
+ const events = type === 'all' ? this.eventAll : this.eventCurrent;
|
|
|
|
+ if (!events[event]) {
|
|
|
|
+ events[event] = [];
|
|
}
|
|
}
|
|
|
|
+ events[event].push(callback);
|
|
|
|
|
|
if (['seeking'].indexOf(event) === -1) {
|
|
if (['seeking'].indexOf(event) === -1) {
|
|
for (let i = 0; i < this.videos.length; i++) {
|
|
for (let i = 0; i < this.videos.length; i++) {
|
|
@@ -134,4 +127,4 @@ class Video {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-module.exports = Video;
|
|
|
|
|
|
+module.exports = Video;
|