压缩字符

This commit is contained in:
Harvey committed 2019-11-27 15:46:55 +08:00
1 parent 2df60a78ff
commit 5f40463713
40 files changed
+385 -481

No files matched your search

+22 -40
View File
@@ -3,53 +3,35 @@ import { def } from '../utils';
export default function switchMix(art, player) {
const { i18n, notice, option } = art;
function switchUrl(url, name, currentTime) {
if (url === player.url) return Promise.resolve(url);
URL.revokeObjectURL(player.url);
return player.attachUrl(url).then(() => {
option.url = url;
player.playbackRate = false;
player.aspectRatio = false;
art.once('video:canplay', () => {
player.currentTime = currentTime;
});
if (player.playing) {
player.play = true;
}
if (name) {
notice.show = `${i18n.get('Switch video')}: ${name}`;
}
art.emit('switch', url);
});
}
def(player, 'switchQuality', {
value: (url, name) => {
if (url !== player.url) {
URL.revokeObjectURL(player.url);
const { currentTime, playing } = player;
return player.attachUrl(url).then(() => {
option.url = url;
player.playbackRate = false;
player.aspectRatio = false;
art.on('ready', () => {
player.currentTime = currentTime;
});
if (playing) {
player.play = true;
}
if (name) {
notice.show(`${i18n.get('Switch video')}: ${name}`);
}
art.emit('switch', url);
});
}
return null;
return switchUrl(url, name, player.currentTime);
},
});
def(player, 'switchUrl', {
value: (url, name) => {
if (url !== player.url) {
URL.revokeObjectURL(player.url);
const { playing } = player;
return player.attachUrl(url).then(() => {
option.url = url;
player.playbackRate = false;
player.aspectRatio = false;
art.on('ready', () => {
player.currentTime = 0;
});
if (playing) {
player.play = true;
}
if (name) {
notice.show(`${i18n.get('Switch video')}: ${name}`);
}
art.emit('switch', url);
});
}
return null;
return switchUrl(url, name, 0);
},
});
}