mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-15 17:16:16 -08:00
37 lines
1022 B
JavaScript
37 lines
1022 B
JavaScript
import { getExt, def, sleep } from '../utils';
|
|
|
|
export default function urlMix(art) {
|
|
const {
|
|
option,
|
|
template: { $video },
|
|
} = art;
|
|
|
|
def(art, 'url', {
|
|
get() {
|
|
return $video.currentSrc;
|
|
},
|
|
set(url) {
|
|
const typeName = option.type || getExt(url);
|
|
const typeCallback = option.customType[typeName];
|
|
if (typeName && typeCallback) {
|
|
sleep().then(() => {
|
|
art.loading.show = true;
|
|
typeCallback.call(art, $video, url, art);
|
|
});
|
|
} else {
|
|
if (art.url && art.url !== url) {
|
|
art.once('video:canplay', () => {
|
|
if (art.isReady) {
|
|
art.emit('restart');
|
|
}
|
|
});
|
|
}
|
|
|
|
$video.src = url;
|
|
art.option.url = url;
|
|
art.emit('url', url);
|
|
}
|
|
},
|
|
});
|
|
}
|