mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
压缩字符
This commit is contained in:
1 parent
2df60a78ff
commit
5f40463713
40 files changed
+385
-481
No files matched your search
@@ -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);
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user