mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 13:21:20 -08:00
改变flv插件加载方式
This commit is contained in:
1 parent
efb5f69dab
commit
7264d0b3a3
11 files changed
+84
-103
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import config from './config';
|
||||
|
||||
export default class CreatMediaSource {
|
||||
constructor(flv) {
|
||||
this.flv = flv;
|
||||
this.creatUrl();
|
||||
this.eventBind();
|
||||
}
|
||||
|
||||
creatUrl() {
|
||||
const {
|
||||
options: { mediaElement },
|
||||
events: { destroyEvents },
|
||||
} = this.flv;
|
||||
this.mediaSource = new MediaSource();
|
||||
const url = URL.createObjectURL(this.mediaSource);
|
||||
destroyEvents.push(() => {
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
mediaElement.src = url;
|
||||
}
|
||||
|
||||
eventBind() {
|
||||
const {
|
||||
events: { proxy },
|
||||
} = this.flv;
|
||||
|
||||
config.mediaSource.events.forEach(eventName => {
|
||||
proxy(this.mediaSource, eventName, event => {
|
||||
this.flv.emit(`mediaSource:${event.type}`, event);
|
||||
});
|
||||
});
|
||||
|
||||
config.sourceBufferList.events.forEach(eventName => {
|
||||
proxy(this.mediaSource.sourceBuffers, eventName, event => {
|
||||
this.flv.emit(`sourceBuffers:${event.type}`, event);
|
||||
});
|
||||
proxy(this.mediaSource.activeSourceBuffers, eventName, event => {
|
||||
this.flv.emit(`activeSourceBuffers:${event.type}`, event);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user