fix(android): Reset prepared state on ExoPlayer STATE_IDLE in audioplayers_android_exo#1999
Open
leonardo-oliveir-a wants to merge 1 commit into
Open
Conversation
…ayers_android_exo STATE_IDLE was a no-op TODO. ExoPlayer enters IDLE after a playback error (and after stop()/release()), and from IDLE it cannot play again without prepare(). Keeping prepared=true after an error leaves both the wrapper and the Dart side believing the player is usable: resume() calls play() on an idle player (silent no-op) and the Dart side never receives audio.onPrepared(false). Reset prepared via a new WrappedPlayer.onIdle() callback. For the intentional paths (creation, stop, release) this is a no-op since the prepared setter only reacts to actual changes and those flows already reset it.
leonardo-oliveir-a
force-pushed
the
fix/exo-idle-prepared
branch
from
June 10, 2026 09:28
e655aa6 to
f236d72
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.
Description
onPlaybackStateChangedcurrently treatsPlayer.STATE_IDLEas a no-op (TODO(gustl22): may can use or leave as no-op). ExoPlayer entersSTATE_IDLEafter a playback error (and afterstop()/release()), and from IDLE it cannot play again without a newprepare().Leaving
prepared = trueafter an error means both sides keep believing the player is usable:WrappedPlayer.resume()callsplay()on an idle player — a silent no-op, audio just never starts;audio.onPreparedwithvalue: false, sogetDuration()/getCurrentPosition()keep being queried on a dead player.This resets
preparedvia a newWrappedPlayer.onIdle()callback. For the intentional IDLE paths (player creation,release(), source set tonull) this is a no-op: thepreparedsetter only reacts to actual value changes, and those flows already reset it before the async listener callback arrives.Checklist
fix:,feat:,docs:etc).onIdle()explaining when it fires and why.examples— reproducible in the example app: stream a URL, kill connectivity mid-playback until ExoPlayer errors out, observe that without this patch noonPrepared(false)event arrives.Breaking Change
Related Issues
Complements the error path of #1721 (background audio stops and never recovers): after this change, apps can at least observe the unprepared state and re-prepare.