移除大部分异步操作

This commit is contained in:
Harvey Zack committed 2018-11-28 13:15:45 +08:00
1 parent 3fb41eedf7
commit 450e4ac879
8 files changed
+82 -90

No files matched your search

+12 -10
View File
@@ -1,4 +1,4 @@
import { getExt } from '../utils';
import { getExt, sleep } from '../utils';
export default function attachUrlMix(art, player) {
const {
@@ -15,15 +15,17 @@ export default function attachUrlMix(art, player) {
value: url => {
const typeName = type || getExt(url);
const typeCallback = customType[typeName];
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);
}
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);
}
});
},
});
}