mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-17 10:01:20 -08:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { def } from '../utils';
|
|
|
|
export default function switchMix(art, player) {
|
|
const { i18n, option, notice } = art;
|
|
|
|
function switchUrl(url, name, currentTime) {
|
|
if (url === player.url) return;
|
|
URL.revokeObjectURL(player.url);
|
|
const { playing } = player;
|
|
player.url = url;
|
|
art.once('video:canplay', () => {
|
|
player.playbackRate = false;
|
|
player.aspectRatio = false;
|
|
player.flip = 'normal';
|
|
player.autoSize = option.autoSize;
|
|
player.currentTime = currentTime;
|
|
art.notice.show = '';
|
|
if (playing) {
|
|
player.play();
|
|
}
|
|
});
|
|
if (name) {
|
|
notice.show = `${i18n.get('Switch video')}: ${name}`;
|
|
}
|
|
art.emit('switch', url);
|
|
}
|
|
|
|
def(player, 'switchQuality', {
|
|
value: (url, name) => {
|
|
return switchUrl(url, name, player.currentTime);
|
|
},
|
|
});
|
|
|
|
def(player, 'switchUrl', {
|
|
value: (url, name) => {
|
|
return switchUrl(url, name, 0);
|
|
},
|
|
});
|
|
}
|