Files
ArtPlayer/packages/artplayer/src/player/switchMix.js
T
2018-11-21 19:45:44 +08:00

29 lines
838 B
JavaScript

export default function switchMix(art, player) {
const {
refs: { $video },
i18n,
notice,
isPlaying,
option,
} = art;
Object.defineProperty(player, 'switch', {
value: (url, name = 'unknown') => {
if (url !== option.url) {
const { currentTime } = player;
art.emit('beforeMountUrl', url);
$video.src = player.mountUrl(url);
option.url = url;
player.playbackRateRemove();
player.aspectRatioRemove();
player.seek(currentTime);
if (isPlaying) {
player.play();
}
notice.show(`${i18n.get('Switch video')}: ${name}`);
art.emit('switch', url);
}
},
});
}