mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 08:51:20 -08:00
改变flv插件加载方式
This commit is contained in:
1 parent
efb5f69dab
commit
7264d0b3a3
11 files changed
+84
-103
No files matched your search
@@ -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;
|
||||
Reference in new issue
Block a user