修改多实例时的图标bug

This commit is contained in:
Harvey Zack committed 2019-04-16 14:26:16 +08:00
1 parent 1573364202
commit 381a7e657e
7 files changed
+170 -138

No files matched your search

+30 -24
View File
@@ -1,4 +1,4 @@
import { getExt, sleep } from '../utils';
import { getExt, sleep, errorHandle } from '../utils';
export default function attachUrlMix(art, player) {
const {
@@ -7,31 +7,37 @@ export default function attachUrlMix(art, player) {
} = art;
Object.defineProperty(player, 'attachUrl', {
value: url => sleep().then(() => {
function attachUrl(videoUrl) {
const typeName = type || getExt(videoUrl);
const typeCallback = customType[typeName];
if (typeName && typeCallback) {
art.loading.show();
art.emit('beforeCustomType', typeName);
typeCallback.call(art, $video, videoUrl, art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl');
$video.src = videoUrl;
art.emit('afterAttachUrl');
value: url =>
sleep().then(() => {
function attachUrl(videoUrl) {
const typeName = type || getExt(videoUrl);
const typeCallback = customType[typeName];
if (typeName && typeCallback) {
art.loading.show();
art.emit('beforeCustomType', typeName);
typeCallback.call(art, $video, videoUrl, art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl');
$video.src = videoUrl;
art.emit('afterAttachUrl');
}
return Promise.resolve(videoUrl);
}
return Promise.resolve(videoUrl);
}
if (typeof url === 'function') {
return url.call(art).then(videoUrl => {
art.loading.show();
return attachUrl(videoUrl);
});
}
if (typeof url === 'function') {
const result = url.call(art);
errorHandle(
typeof result.then === 'function',
'If url is a function, it needs to return a promise.',
);
return result.then(videoUrl => {
art.loading.show();
return attachUrl(videoUrl);
});
}
return attachUrl(url);
}),
return attachUrl(url);
}),
});
}