添加字幕插件

This commit is contained in:
Harvey Zack committed 2018-11-23 16:23:14 +08:00
1 parent 5f384fb04d
commit 1667457188
24 files changed
+492 -247

No files matched your search

+15 -12
View File
@@ -71,6 +71,7 @@ class Artplayer extends Emitter {
quality: [],
controls: [],
highlight: [],
plugins: [],
thumbnails: {
url: '',
number: 60,
@@ -90,18 +91,6 @@ class Artplayer extends Emitter {
};
}
static use(...args) {
const plugin = args[0];
const installedPlugins = this.plugins || (this.plugins = []);
if (installedPlugins.indexOf === -1) {
installedPlugins.push(plugin);
args.unshift(this);
plugin(...args.slice(1));
this.prototype.emit('use', plugin);
}
return this;
}
init() {
this.isFocus = false;
this.isPlaying = false;
@@ -136,6 +125,20 @@ class Artplayer extends Emitter {
id += 1;
this.id = id;
Artplayer.instances.push(this);
this.plugins = [];
this.option.plugins.forEach((plugin, index) => {
const resule = plugin(this);
let pluginName = '';
if (resule && resule.name) {
pluginName = resule.name;
} else if (plugin.name) {
pluginName = plugin.name;
} else {
pluginName = `plugin${index}`;
}
this.plugins[pluginName] = resule;
});
}
destroy(removeHtml = false) {