改变flv插件加载方式

This commit is contained in:
Harvey Zack committed 2018-12-19 09:20:45 +08:00
1 parent efb5f69dab
commit 7264d0b3a3
11 files changed
+84 -103

No files matched your search

+52 -17
View File
@@ -1,22 +1,57 @@
import Flv from './flv';
import Emitter from 'tiny-emitter';
import checkSupport from './utils/checkSupport';
import EventProxy from './eventProxy';
import CreatMediaSource from './creatMediaSource';
import FlvParse from './flvParse';
import * as utils from './utils';
import config from './config';
function artplayerPluginFlv(art) {
let flv = null;
let id = 0;
class Flv extends Emitter {
constructor(options) {
super();
this.options = Object.assign({}, Flv.DEFAULTS, options);
checkSupport(this.options);
id += 1;
this.id = id;
Flv.instances.push(this);
}
art.on('destroy', () => {
if (flv) {
flv.destroy();
}
});
static get DEFAULTS() {
return {
mediaElement: '',
url: '',
};
}
return {
flv,
init: (mediaElement, url) => {
flv = new Flv(mediaElement, url);
flv.load();
},
};
static get version() {
return '__VERSION__';
}
static get config() {
return config;
}
static get utils() {
return utils;
}
load() {
this.events = new EventProxy(this);
this.mediaSource = new CreatMediaSource(this);
this.flvData = new FlvParse(this);
}
destroy() {
this.events.destroy();
Flv.instances.splice(Flv.instances.indexOf(this), 1);
this.emit('destroy');
}
}
window.artplayerPluginFlv = artplayerPluginFlv;
export default artplayerPluginFlv;
Object.defineProperty(Flv, 'instances', {
value: [],
});
window.Flv = Flv;
export default Flv;