mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 01:21:20 -08:00
创建mse
This commit is contained in:
1 parent
50d1457e7e
commit
2e0d70292b
9 files changed
+99
-19
No files matched your search
@@ -0,0 +1,18 @@
|
||||
export default function checkSupport(art) {
|
||||
const {
|
||||
utils: { errorHandle },
|
||||
config: { mimeCodec },
|
||||
} = art.constructor;
|
||||
|
||||
const {
|
||||
template: { $video },
|
||||
} = art;
|
||||
|
||||
const canPlay = $video.canPlayType(mimeCodec.mp4);
|
||||
errorHandle(
|
||||
window.MediaSource &&
|
||||
window.MediaSource.isTypeSupported(mimeCodec.mp4) &&
|
||||
(canPlay === 'probably' || canPlay === 'maybe'),
|
||||
`Unsupported MIME type or codec: ${mimeCodec.mp4}`,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export default class CreatMediaSource {
|
||||
constructor(art) {
|
||||
this.mediaSource = new MediaSource();
|
||||
this.url = URL.createObjectURL(this.mediaSource);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,22 @@
|
||||
import checkSupport from './checkSupport';
|
||||
import CreatMediaSource from './creatMediaSource';
|
||||
|
||||
class Flv {
|
||||
constructor(art) {
|
||||
checkSupport(art);
|
||||
this.mediaSource = new CreatMediaSource(art);
|
||||
this.load = url => {
|
||||
console.log(url);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function artplayerPluginFlv(art) {
|
||||
const flv = new Flv(art);
|
||||
return {
|
||||
load: url => new Promise(resolve => {
|
||||
resolve('https://blog.zhw-island.com/assets-cdn/video/one-more-time-one-more-chance-480p.mp4');
|
||||
flv.load(url);
|
||||
return resolve(flv.mediaSource.url);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ let id = 0;
|
||||
class Artplayer extends Emitter {
|
||||
constructor(option) {
|
||||
super();
|
||||
utils.errorHandle(typeof window.Promise === 'function', "Unsupported 'Promise' method");
|
||||
utils.errorHandle(typeof window.fetch === 'function', "Unsupported 'fetch' method");
|
||||
this.option = utils.mergeDeep(Artplayer.DEFAULTS, option);
|
||||
optionValidator(this.option, scheme);
|
||||
this.init();
|
||||
@@ -148,4 +150,4 @@ Object.defineProperty(Artplayer, 'instances', {
|
||||
});
|
||||
|
||||
window.Artplayer = Artplayer;
|
||||
export default Artplayer;
|
||||
export default Artplayer;
|
||||
Reference in new issue
Block a user