Skip to content

Commit

Permalink
Fix pause for saves
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrews54757 committed Oct 27, 2024
1 parent 3114b64 commit 2b9142f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
13 changes: 12 additions & 1 deletion chrome/player/modules/dash2mp4/dash2mp4.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
11 changes: 10 additions & 1 deletion chrome/player/players/dash/DashPlayer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
11 changes: 10 additions & 1 deletion chrome/player/players/hls/HLSPlayer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
11 changes: 10 additions & 1 deletion chrome/player/players/mp4/MP4Player.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2b9142f

Please sign in to comment.