This commit is contained in:
Harvey Zack committed 2018-12-14 14:10:39 +08:00
1 parent 9f90774b4f
commit 3f451aa047
12 files changed
+191 -147

No files matched your search

+13 -19
View File
@@ -6,37 +6,31 @@ export default function attachUrlMix(art, player) {
template: { $video },
} = art;
Object.defineProperty(player, 'returnUrl', {
writable: true,
value: url => url,
});
Object.defineProperty(player, 'attachUrl', {
value: url => {
value: url => sleep().then(() => {
function attachUrl(videoUrl) {
const typeName = type || getExt(videoUrl);
const typeCallback = customType[typeName];
return sleep().then(() => {
if (typeName && typeCallback) {
art.emit('beforeCustomType', typeName);
typeCallback($video, player.returnUrl(videoUrl), art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl', videoUrl);
$video.src = player.returnUrl(videoUrl);
art.emit('afterAttachUrl', $video.src);
}
});
if (typeName && typeCallback) {
art.emit('beforeCustomType', typeName);
typeCallback.call(art, $video, videoUrl, art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl', videoUrl);
$video.src = videoUrl;
art.emit('afterAttachUrl', videoUrl);
}
return Promise.resolve(videoUrl);
}
if (typeof url === 'function') {
return url().then(videoUrl => {
return url.call(art).then(videoUrl => {
art.loading.show();
return attachUrl(videoUrl);
});
}
return attachUrl(url);
},
}),
});
}