From 2d61f497b363aa01d173595d4149a5caec4555c4 Mon Sep 17 00:00:00 2001 From: Artur Parkhisenko Date: Thu, 7 Mar 2024 08:55:43 -0800 Subject: [PATCH] chore: change code example transmuxer event listeners (#438) --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8bf35dac..34c906cb 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,8 @@ Here we put all of this together in a very basic example player. data.set(segment.data, segment.initSegment.byteLength); console.log(muxjs.mp4.tools.inspect(data)); sourceBuffer.appendBuffer(data); + // reset the 'data' event listener to just append (moof/mdat) boxes to the Source Buffer + transmuxer.off('data'); }) fetch(segments.shift()).then((response)=>{ @@ -294,10 +296,9 @@ Here we put all of this together in a very basic example player. } function appendNextSegment(){ - // reset the 'data' event listener to just append (moof/mdat) boxes to the Source Buffer - transmuxer.off('data'); transmuxer.on('data', (segment) =>{ sourceBuffer.appendBuffer(new Uint8Array(segment.data)); + transmuxer.off('data'); }) if (segments.length == 0){