mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-09 20:26:16 -08:00
增加播放方法的错误捕捉
This commit is contained in:
1 parent
d7cb9d16b8
commit
a7bebabb6d
3 files changed
+23
-20
No files matched your search
+10
-9
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user