Files
ArtPlayer/packages/artplayer/src/player/urlMix.js
T
2020-11-22 21:20:59 +08:00

32 lines
880 B
JavaScript

import { getExt, def, sleep } from '../utils';
export default function urlMix(art, player) {
const {
option,
template: { $video },
} = art;
def(player, 'url', {
get() {
return $video.src;
},
set(url) {
const typeName = option.type || getExt(url);
const typeCallback = option.customType[typeName];
if (typeName && typeCallback) {
sleep().then(() => {
art.loading.show = true;
const result = typeCallback.call(art, $video, url, art);
def(art, typeName, {
value: result,
});
});
} else {
$video.src = url;
art.option.url = url;
art.emit('url', url);
}
},
});
}