mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 01:21:20 -08:00
合并字幕插件
This commit is contained in:
1 parent
6c61a5678b
commit
acdb272393
17 files changed
+149
-165
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import artplayerPluginSubtitle from './artplayer-plugin-subtitle';
|
||||
import artplayerPluginLocalPreview from './artplayer-plugin-localPreview';
|
||||
|
||||
export default class Plugins {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.id = 0;
|
||||
|
||||
this.add(artplayerPluginSubtitle);
|
||||
this.add(artplayerPluginLocalPreview);
|
||||
art.option.plugins.forEach(plugin => {
|
||||
this.add(plugin);
|
||||
});
|
||||
}
|
||||
|
||||
add(plugin) {
|
||||
this.id += 1;
|
||||
const result = plugin.call(this, this.art);
|
||||
let pluginName = '';
|
||||
if (result && result.name) {
|
||||
pluginName = result.name;
|
||||
} else if (plugin.name) {
|
||||
pluginName = plugin.name;
|
||||
} else {
|
||||
pluginName = `plugin${this.id}`;
|
||||
}
|
||||
this[pluginName] = result;
|
||||
this.art.emit('plugin:add', plugin);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user