Skip to content

Commit

Permalink
Handle exceptions raised by the addSourceBuffer method
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed Jul 23, 2024
1 parent 23d1ce8 commit fb37fff
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ export const useMSEMediaPlayer = ({
} else {
mimeCodec = Utf8ArrayToStr(decoded_arr);
}
mseSourceBuffer = mse.addSourceBuffer(
`video/mp4; codecs="${mimeCodec}"`,
);
try {
mseSourceBuffer = mse.addSourceBuffer(
`video/mp4; codecs="${mimeCodec}"`,
);
} catch (error) {
onError && onError(error);
return;
}
mseSourceBuffer.mode = "segments";
if (mseQueue.length > 0 && !mseSourceBuffer.updating) {
mseSourceBuffer.addEventListener("updateend", pushPacket);
Expand Down

0 comments on commit fb37fff

Please sign in to comment.