添加flv.js演示

This commit is contained in:
Harvey Zack committed 2018-11-24 17:08:36 +08:00
1 parent c7c9e0a311
commit 8a9f70720a
11 files changed
+143 -33

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ export default class Mse {
init() {
const { player, events } = this.art;
this.setMimeCodec();
Object.defineProperty(player, 'mountUrl', {
Object.defineProperty(player, 'returnUrl', {
value: () => {
this.mediaSource = new MediaSource();
const url = URL.createObjectURL(this.mediaSource);
@@ -0,0 +1,26 @@
export default function attachUrlMix(art, player) {
const {
option: { type, customType },
refs: { $video },
} = art;
Object.defineProperty(player, 'returnUrl', {
writable: true,
value: url => url,
});
Object.defineProperty(player, 'attachUrl', {
value: url => {
const typeCallback = customType[type];
if (type && typeCallback) {
art.emit('beforeCustomType', url);
typeCallback($video, player.returnUrl(url), art);
art.emit('afterCustomType', url);
} else {
art.emit('beforeAttachUrl', url);
$video.src = player.returnUrl(url);
art.emit('afterAttachUrl', url);
}
},
});
}
+1 -3
View File
@@ -26,8 +26,6 @@ export default function attrInit(art, player) {
}
sleep().then(() => {
art.emit('beforeMountUrl', option.url);
$video.src = player.mountUrl(option.url);
art.emit('afterMountUrl', option.url);
player.attachUrl(option.url);
});
}
+1 -2
View File
@@ -80,8 +80,7 @@ export default function eventInit(art, player) {
if (reconnectTime < maxReconnectTime) {
sleep(1000).then(() => {
reconnectTime += 1;
art.emit('beforeMountUrl', option.url);
$video.src = player.mountUrl(option.url);
player.attachUrl(option.url);
notice.show(`${i18n.get('Reconnect')}: ${reconnectTime}`);
});
} else {
+2 -2
View File
@@ -1,4 +1,4 @@
import mountUrlMix from './mountUrlMix';
import attachUrlMix from './attachUrlMix';
import attrInit from './attrInit';
import eventInit from './eventInit';
import playMix from './playMix';
@@ -22,7 +22,7 @@ import flipMix from './flipMix';
export default class Player {
constructor(art) {
mountUrlMix(art, this);
attachUrlMix(art, this);
eventInit(art, this);
attrInit(art, this);
playMix(art, this);
@@ -1,6 +1,5 @@
export default function switchMix(art, player) {
const {
refs: { $video },
i18n,
notice,
option,
@@ -11,9 +10,7 @@ export default function switchMix(art, player) {
if (url !== option.url) {
const { isPlaying } = art;
const { currentTime } = player;
art.emit('beforeMountUrl', url);
$video.src = player.mountUrl(url);
art.emit('afterMountUrl', url);
player.attachUrl(url);
option.url = url;
player.playbackRateRemove();
player.aspectRatioRemove();