Repository navigation
Add onMediaError instance method - #1379
Open
captbaritone wants to merge 2 commits into
Open
captbaritone wants to merge 2 commits into
captbaritone wants to merge 2 commits into
Conversation
When a track fails to load or decode, Webamp logs the error and continues as if the track had ended, so embedders could not tell an unplayable file from the end of a track. ElementSource now emits an "error" event with the MediaError code, which Media re-emits and the media middleware dispatches as MEDIA_ERROR. The new webamp.onMediaError(cb) subscribes to it. The existing behavior of treating the error as the end of the track is unchanged.
✅ Deploy Preview for tourmaline-kringle-c98715 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: +132 B (+0.03%) Total Size: 490 kB 📦 View Changed
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a track can't be fetched or decoded,
ElementSourcelogs the error, then triggersendedand sets the status to STOPPED. That keeps Webamp from getting stuck, but it means an embedder can't tell an undecodable file from the end of a track. agentcloud currently works around this by probing the same URL with a hidden<audio>element.This adds a public signal:
codeis the underlyingMediaError.code. It's passed in an object so more fields can be added later without breaking callers.Implementation
ElementSourceemits"error"with the code, just before its existing"ended".Mediare-emits it, and the media middleware dispatches a newMEDIA_ERRORaction.onMediaErrorsubscribes to that action, the same wayonClose/onMinimizedo.onMediaErrorbefore the resulting track change.Documented in the instance methods docs.
Testing
onMediaError.test.tsconstructs a realWebampLazywith a fake media class via the existing__customMediaClassoption, emits"error", and checks that the callback gets{ code }and that unsubscribing works.tsc,eslint,prettier --checkandvitest runpass locally.