mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-16 17:46:17 -08:00
32 lines
1003 B
JavaScript
32 lines
1003 B
JavaScript
import { getExt, sleep } from '../utils';
|
|
|
|
export default function attachUrlMix(art, player) {
|
|
const {
|
|
option: { type, customType },
|
|
template: { $video },
|
|
} = art;
|
|
|
|
Object.defineProperty(player, 'returnUrl', {
|
|
writable: true,
|
|
value: url => url,
|
|
});
|
|
|
|
Object.defineProperty(player, 'attachUrl', {
|
|
value: url => {
|
|
const typeName = type || getExt(url);
|
|
const typeCallback = customType[typeName];
|
|
return sleep().then(() => {
|
|
if (typeName && typeCallback) {
|
|
art.emit('beforeCustomType', typeName);
|
|
typeCallback($video, player.returnUrl(url), art);
|
|
art.emit('afterCustomType', typeName);
|
|
} else {
|
|
art.emit('beforeAttachUrl', url);
|
|
$video.src = player.returnUrl(url);
|
|
art.emit('afterAttachUrl', $video.src);
|
|
}
|
|
});
|
|
},
|
|
});
|
|
}
|