fix(HTMLVideo): recover from hls.js errors to prevent silent audio#142
Open
Aqu1tain wants to merge 1 commit intoStremio:masterfrom
Open
fix(HTMLVideo): recover from hls.js errors to prevent silent audio#142Aqu1tain wants to merge 1 commit intoStremio:masterfrom
Aqu1tain wants to merge 1 commit intoStremio:masterfrom
Conversation
ab322b8 to
7a2ce33
Compare
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.
Summary
Adds an
Hls.Events.ERRORlistener inHTMLVideoso a small set of stalling conditions that hls.js does not recover from on its own no longer leave audio silent while video keeps playing.Why
HTMLVideo.jsconstructs anHlsinstance with no error listener and never callsrecoverMediaError,swapAudioCodec, orstartLoad. When hls.js exhausts retries onbufferStalledError,bufferAppendingError,audioTrackLoadError,audioTrackLoadTimeOut, or hits a fatalNETWORK_ERROR/MEDIA_ERROR, the audio source buffer can stall while the video element keeps decoding video. The host UI shows normal, non-muted state because nothing togglesvideoElement.mutedorvideoElement.volume. Users see silent playback until they reload. Only HTMLVideo is affected; ShellVideo and external players bypass hls.js.Behavior
startLoad()only for the four known stalling details. All other non-fatal errors are left to hls.js's own state machine.NETWORK_ERROR:startLoad().MEDIA_ERROR: first occurrence callsrecoverMediaError(); a second within 3s addsswapAudioCodec()before recovery. Capped at 3 attempts; counter resets onFRAG_BUFFERED.videoElement.onerrorpath continues to map decode errors as before.Test plan
BUFFER_STALLED_ERRORand verify audio resumes without reload.MEDIA_ERRORand verify audio recovers; force a second within 3s and verify codec swap kicks in.MEDIA_ERRORs and verify the listener stops intervening after 3 attempts so the video error path takes over.npm run lintpasses.