mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 17:01:20 -08:00
update switchMix.js
This commit is contained in:
1 parent
c301844a87
commit
37dc0a8203
7 files changed
+65
-62
No files matched your search
@@ -1,42 +1,46 @@
|
||||
import { def } from '../utils';
|
||||
|
||||
export default function switchMix(art) {
|
||||
const { i18n, option, notice } = art;
|
||||
function switchUrl(url, currentTime) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (url === art.url) return;
|
||||
const { playing, aspectRatio, playbackRate, option } = art;
|
||||
|
||||
function switchUrl(url, name, currentTime) {
|
||||
return new Promise((resolve) => {
|
||||
if (url === art.url) return resolve(url);
|
||||
const { playing } = art;
|
||||
art.pause();
|
||||
URL.revokeObjectURL(art.url);
|
||||
art.url = url;
|
||||
art.once('video:error', reject);
|
||||
art.once('video:canplay', () => {
|
||||
art.playbackRate = false;
|
||||
art.aspectRatio = false;
|
||||
art.flip = 'normal';
|
||||
art.autoSize = option.autoSize;
|
||||
art.playbackRate = playbackRate;
|
||||
art.aspectRatio = aspectRatio;
|
||||
art.currentTime = currentTime;
|
||||
art.notice.show = '';
|
||||
|
||||
if (option.autoSize) {
|
||||
art.autoSize = true;
|
||||
}
|
||||
|
||||
if (playing) {
|
||||
art.play();
|
||||
}
|
||||
if (name) {
|
||||
notice.show = `${i18n.get('Switch Video')}: ${name}`;
|
||||
}
|
||||
resolve(url);
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
def(art, 'switchQuality', {
|
||||
value: (url, name) => {
|
||||
return switchUrl(url, name, art.currentTime);
|
||||
value: (url) => {
|
||||
return switchUrl(url, art.currentTime);
|
||||
},
|
||||
});
|
||||
|
||||
def(art, 'switchUrl', {
|
||||
value: (url, name) => {
|
||||
return switchUrl(url, name, 0);
|
||||
value: (url) => {
|
||||
return switchUrl(url, 0);
|
||||
},
|
||||
});
|
||||
|
||||
def(art, 'switch', {
|
||||
set: art.switchUrl,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user