Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample code: It does not work. #407

Closed
jynxio opened this issue Jan 7, 2022 · 4 comments · Fixed by #438
Closed

Sample code: It does not work. #407

jynxio opened this issue Jan 7, 2022 · 4 comments · Fixed by #438

Comments

@jynxio
Copy link

jynxio commented Jan 7, 2022

Discretion

The sample code of README.md does not work, it will throw this error:

Uncaught (in promise) DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer has been removed from the parent media source.

The specific location of the error is here:

<script>
    function appendNextSegment () {
        // ......
        transmuxer.on('data', (segment) => {
            sourceBuffer.appendBuffer(new Uint8Array(segment.data)); // 👈 here!
        })
        // ......
    }
</script>

Screenshot

Snipaste_2022-01-07_16-39-24

Environment

platform: chrome ( 97.0.4692.71 ), Windows10

@erickythierry
Copy link

same here. did you find any solution?

@jynxio
Copy link
Author

jynxio commented Feb 22, 2022

same here. did you find any solution?

not yet

@arturparkhisenko
Copy link
Contributor

In addition to that - the latest release didn't publish assets like it did before, so that's also one more reason why the sample code fails. Talking about this URL https://github.com/videojs/mux.js/releases/latest/download/mux.js.

@arturparkhisenko
Copy link
Contributor

But the core of the reported problem is that with the current code sample, we're getting two data events for one updateend event of source buffer. So yes the current SourceBuffer is still in the appendBuffer state.

The simplest 1 line change we can make seems to me like this:

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'); // ⬅️ 🆕 This is added, to close the listener for the current append.
  })
  // ... rest of the code
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants