增加播放方法的错误捕捉

This commit is contained in:
Harvey Zack committed 2018-11-01 10:59:39 +08:00
1 parent d7cb9d16b8
commit a7bebabb6d
3 files changed
+23 -20

No files matched your search

+10 -9
View File
@@ -60,12 +60,7 @@ export default class Player {
this.art.mask.show();
this.art.loading.hide();
if (option.autoplay) {
const promise = this.play();
if (promise !== undefined) {
promise.then().catch(err => {
console.warn(err);
});
}
this.play();
}
});
@@ -104,8 +99,10 @@ export default class Player {
this.art.loading.hide();
this.art.controls.hide();
$player.classList.add('artplayer-error');
notice.show(i18n.get('Video load failed'), false);
this.art.destroy();
sleep(1000).then(() => {
notice.show(i18n.get('Video load failed'), false);
this.art.destroy();
});
}
});
}
@@ -113,9 +110,13 @@ export default class Player {
play() {
const { refs: { $video }, i18n, notice } = this.art;
const promise = $video.play();
if (promise !== undefined) {
promise.then().catch(err => {
notice.show(err, true, 3000);
});
}
notice.show(i18n.get('Play'));
this.art.emit('play', $video);
return promise;
}
pause() {