diff --git a/chrome/player/modules/dash2mp4/dash2mp4.mjs b/chrome/player/modules/dash2mp4/dash2mp4.mjs index 01b283b5..315435f5 100644 --- a/chrome/player/modules/dash2mp4/dash2mp4.mjs +++ b/chrome/player/modules/dash2mp4/dash2mp4.mjs @@ -17,9 +17,20 @@ export class DASH2MP4 extends EventEmitter { }); return await this.converter.convert(videoDuration, videoInitSegment, audioDuration, audioInitSegment, zippedFragments); } catch (e) { - if (e.message === 'Cancelled') { + const mergerErrors = [ + 'Video codec not supported!', + 'Audio codec not supported!', + 'Video is not an mp4!', + 'Audio is not an mp4!', + ]; + if (!mergerErrors.includes(e.message)) { throw e; } + + if (!window.VideoDecoder || !window.VideoEncoder || !window.AudioDecoder || !window.AudioEncoder) { + throw e; + } + const {Reencoder} = await import('../reencoder/reencoder.mjs'); this.converter = new Reencoder(this.registerCancel); this.converter.on('progress', (progress) => { diff --git a/chrome/player/players/dash/DashPlayer.mjs b/chrome/player/players/dash/DashPlayer.mjs index bc51e2c8..31a4a97e 100644 --- a/chrome/player/players/dash/DashPlayer.mjs +++ b/chrome/player/players/dash/DashPlayer.mjs @@ -409,7 +409,16 @@ export default class DashPlayer extends EventEmitter { data.fragment.addReference(ReferenceTypes.SAVER); data.getEntry = async () => { if (data.fragment.status !== DownloadStatus.DOWNLOAD_COMPLETE) { - await this.downloadFragment(data.fragment, -1); + while (true) { + try { + await this.downloadFragment(data.fragment, -1); + break; + } catch (e) { + if (e.message !== 'Aborted download') { + throw e; + } + } + } } data.fragment.removeReference(ReferenceTypes.SAVER); return this.client.downloadManager.getEntry(data.fragment.getContext()); diff --git a/chrome/player/players/hls/HLSPlayer.mjs b/chrome/player/players/hls/HLSPlayer.mjs index d875aefe..27087009 100644 --- a/chrome/player/players/hls/HLSPlayer.mjs +++ b/chrome/player/players/hls/HLSPlayer.mjs @@ -129,7 +129,16 @@ export default class HLSPlayer extends EventEmitter { data.fragment.addReference(ReferenceTypes.SAVER); data.getEntry = async () => { if (data.fragment.status !== DownloadStatus.DOWNLOAD_COMPLETE) { - await this.downloadFragment(data.fragment, -1); + while (true) { + try { + await this.downloadFragment(data.fragment, -1); + break; + } catch (e) { + if (e.message !== 'Aborted download') { + throw e; + } + } + } } data.fragment.removeReference(ReferenceTypes.SAVER); return this.client.downloadManager.getEntry(data.fragment.getContext()); diff --git a/chrome/player/players/mp4/MP4Player.mjs b/chrome/player/players/mp4/MP4Player.mjs index 72844558..288d64a7 100644 --- a/chrome/player/players/mp4/MP4Player.mjs +++ b/chrome/player/players/mp4/MP4Player.mjs @@ -716,7 +716,16 @@ export default class MP4Player extends EventEmitter { } const frag = frags[i]; if (!options.partialSave) { - await this.downloadFragment(frag, -1); + while (true) { + try { + await this.downloadFragment(frag, -1); + break; + } catch (e) { + if (e.message !== 'Aborted download') { + throw e; + } + } + } frag.removeReference(ReferenceTypes.SAVER); } if (frag.status === DownloadStatus.DOWNLOAD_COMPLETE) {