不合理

This commit is contained in:
Harvey Zack committed 2018-12-14 16:48:37 +08:00
1 parent f8400002c2
commit c6869686c3
4 files changed
+397 -320

No files matched your search

+29 -3
View File
@@ -1,16 +1,42 @@
import Emitter from 'tiny-emitter';
import CheckSupport from './checkSupport';
import CreatMediaSource from './creatMediaSource';
import { errorHandle } from './utils';
class Flv extends Emitter {
constructor(mediaElement, url) {
super();
this.mediaElement = mediaElement;
this.url = url;
this.support = new CheckSupport();
if (mediaElement) {
this.attachMediaElement(mediaElement);
}
if (url) {
this.loadUrl(url);
}
}
attachMediaElement(mediaElement) {
errorHandle(
mediaElement instanceof HTMLVideoElement && mediaElement.tagName === 'VIDEO',
"The 'mediaElement' does not seem to be a HTMLVideoElement",
);
this.mediaElement = mediaElement;
return this;
}
loadUrl(url) {
const type = typeof url;
errorHandle(type === 'string', `The 'url' require 'string' type, but got '${type}'`);
this.url = url;
return this;
}
start() {
this.mediaSource = new CreatMediaSource();
console.log('start');
return this;
}
}
window.Flv = Flv;
export default Flv;
export default Flv;
+2 -1
View File
@@ -4,10 +4,11 @@ function artplayerPluginFlv(art) {
const {
template: { $video },
} = art;
const flv = new Flv($video);
return {
load: url =>
new Promise(resolve => {
const flv = new Flv($video, url);
flv.loadUrl(url).start();
return resolve(flv.mediaSource.url);
}),
};