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

fix: Wait for chapters track to be loaded #4228

Merged
merged 2 commits into from May 16, 2022

Commits on May 16, 2022

  1. fix: Wait for chapters track to be loaded

    addChaptersTrack() was already an async method, but it did not wait
    for the chapter data to be loaded by the browser.  The solution is to
    wait for the `load` event on the `<track>` element we create.
    
    To accomplish this, some cleanup and refactoring was done in how
    tracks are managed.  Summary of changes:
    
     - The `addtrack` event, which triggered management of tracks in src=
       playback, is now used for all types of playback.  In src= mode, it
       manages all tracks, and in MSE mode, it only manages chapters
       tracks (which are added to the video element as in src= mode).
     - `processChaptersTrack_()` has been renamed to
       `activateChaptersTrack_()`, since its only job is to set the
       track's mode field to make the browser load it.
     - `activateChaptersTrack_()` is now only ever called via the
       `addtrack` event.
     - `activateChaptersTrack_()` no longer loops over all chapter tracks
       on a timer, and instead only touches the single track it was
       called for.
     - `addSrcTrackElement_()` now returns the HTML `<track>` element it
       creates.
     - `addChaptersTrack()` now awaits a `load` or `error` event to
       complete (or fail) the operation.
     - Existing tests for addChaptersTrack had long delays to work around
       this issue; these delays have simply been removed.
    
    Fixes shaka-project#4186
    joeyparrish committed May 16, 2022
    Copy the full SHA
    77a68f3 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    74d570b View commit details
    Browse the repository at this point in the history