Skip to content

Fix Android PlatformMediaPlayer play/pause#5

Draft
Copilot wants to merge 5 commits intocopilot/migrate-swiftklib-to-kotlinfrom
copilot/fix-play-pause-implementation
Draft

Fix Android PlatformMediaPlayer play/pause#5
Copilot wants to merge 5 commits intocopilot/migrate-swiftklib-to-kotlinfrom
copilot/fix-play-pause-implementation

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Three bugs in the Android PlatformMediaPlayer that together caused play/pause to not work correctly.

  • Wrong ExoPlayer API: play()/pause() were toggling playWhenReady instead of calling exoPlayer.play()/exoPlayer.pause(), which don't fire the correct listener callbacks
  • Missing state propagation: onPlaybackStateChanged doesn't re-fire when play/pause is called while already in STATE_READY, so PLAYING/PAUSED transitions are now driven from onIsPlayingChanged instead; the STATE_READY guard on the pause branch prevents PAUSED from being emitted during IDLE/ENDED teardown
  • Duplicate polling loops: onIsPlayingChanged(true) fires on initial play, seek resume, and buffering recovery — each unconditional handler.post(updateProgressRunnable) spawned an extra self-rescheduling loop; fixed with removeCallbacks before post
override fun onIsPlayingChanged(isPlaying: Boolean) {
    if (isPlaying) {
        _state.value = PlaybackState.PLAYING
        handler.removeCallbacks(updateProgressRunnable) // cancel any in-flight tick
        handler.post(updateProgressRunnable)
    } else if (exoPlayer.playbackState == Player.STATE_READY) {
        _state.value = PlaybackState.PAUSED
    }
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: markst <274318+markst@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix play and pause implementation in PlatformMediaPlayer Fix play/pause broken state on Android PlatformMediaPlayer Feb 25, 2026
Copilot AI requested a review from markst February 25, 2026 08:09
Co-authored-by: markst <274318+markst@users.noreply.github.com>
Copilot AI changed the title Fix play/pause broken state on Android PlatformMediaPlayer Remove redundant removeCallbacks from onIsPlayingChanged Feb 25, 2026
…ed(true)

Co-authored-by: markst <274318+markst@users.noreply.github.com>
Copilot AI changed the title Remove redundant removeCallbacks from onIsPlayingChanged Fix duplicate progress polling loops on Android Feb 25, 2026
Co-authored-by: markst <274318+markst@users.noreply.github.com>
Copilot AI changed the title Fix duplicate progress polling loops on Android Fix Android PlatformMediaPlayer play/pause Feb 25, 2026
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 this pull request may close these issues.

2 participants