Skip to content

Commit

Permalink
fix: clear listeners when resetting media source (#6449)
Browse files Browse the repository at this point in the history
  • Loading branch information
tykus160 authored Apr 17, 2024
1 parent 91f74e7 commit ab36ce7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1845,12 +1845,17 @@ shaka.media.MediaSourceEngine = class {

const totalOfBuffers = streamsByType.size;
let numberOfSourceBufferAdded = 0;
this.eventManager_.listen(sourceBuffers, 'addsourcebuffer', (event) => {
const onSourceBufferAdded = () => {
numberOfSourceBufferAdded++;
if (numberOfSourceBufferAdded === totalOfBuffers) {
sourceBufferAdded.resolve();
this.eventManager_.unlisten(sourceBuffers, 'addsourcebuffer',
onSourceBufferAdded);
}
});
};

this.eventManager_.listen(sourceBuffers, 'addsourcebuffer',
onSourceBufferAdded);

for (const contentType of streamsByType.keys()) {
const stream = streamsByType.get(contentType);
Expand Down

0 comments on commit ab36ce7

Please sign in to comment.