add plugin

This commit is contained in:
Harvey Zack committed 2018-10-11 17:11:55 +08:00
1 parent 0573cb80b0
commit d5d16ed709
2 files changed
+14 -1

No files matched your search

+13
View File
@@ -70,6 +70,19 @@ class Artplayer extends Emitter {
};
}
static use(plugin) {
const installedPlugins = this.plugins || (this.plugins = []);
if (installedPlugins.indexOf(plugin) > -1) {
return this;
}
const args = Array.from(arguments).slice(1);
args.unshift(this);
plugin.apply(null, args);
installedPlugins.push(plugin);
return this;
}
init() {
this.refs = {
container: this.option.container