Skip to content

Fix: Player progress bar freezes on Bluetooth#278

Merged
theovilardo merged 1 commit intomasterfrom
fix-bluetooth-progress-bar
Oct 21, 2025
Merged

Fix: Player progress bar freezes on Bluetooth#278
theovilardo merged 1 commit intomasterfrom
fix-bluetooth-progress-bar

Conversation

@theovilardo
Copy link
Owner

The UI progress slider (WavySlider) would get stuck at the beginning of the track (0:00) when audio playback was routed through a Bluetooth device.

The root cause was a desynchronization between the MediaSession and the MediaController after an audio output change. The MediaController was repeatedly querying a stale position, which remained at 0.

To resolve this, a more direct and robust progress reporting mechanism has been implemented:

  1. A custom SessionCommand (GET_POSITION) has been added to MusicService.kt. This command allows the PlayerViewModel to directly query the ExoPlayer instance's current position, bypassing any potential state desynchronization.
  2. The startProgressUpdates loop in PlayerViewModel.kt has been modified to use this custom command, ensuring the UI always reflects the true playback position.
  3. The DualPlayerEngine's extension renderer mode has been set to PREFER to improve stability.
The UI progress slider (`WavySlider`) would get stuck at the beginning of the track (0:00) when audio playback was routed through a Bluetooth device.

The root cause was a desynchronization between the `MediaSession` and the `MediaController` after an audio output change. The `MediaController` was repeatedly querying a stale position, which remained at 0.

To resolve this, a more direct and robust progress reporting mechanism has been implemented:

1.  A custom `SessionCommand` (`GET_POSITION`) has been added to `MusicService.kt`. This command allows the `PlayerViewModel` to directly query the `ExoPlayer` instance's current position, bypassing any potential state desynchronization.
2.  The `startProgressUpdates` loop in `PlayerViewModel.kt` has been modified to use this custom command, ensuring the UI always reflects the true playback position.
3.  The `DualPlayerEngine`'s extension renderer mode has been set to `PREFER` to improve stability.
@theovilardo theovilardo merged commit 28dd193 into master Oct 21, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

https://github.com/theovilardo/PixelPlay/blob/ab83d9da8772b6075a7cb50e0c9e7e92aff41183/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/PlayerViewModel.kt#L2133-L2134
P0 Badge Import classes used in progress polling command

startProgressUpdates now references SessionCommand and Bundle.EMPTY, but this file does not import either symbol. The compiler will fail with unresolved references when building PlayerViewModel. Add import androidx.media3.session.SessionCommand and import android.os.Bundle (or use fully-qualified names) so the app can compile.


https://github.com/theovilardo/PixelPlay/blob/ab83d9da8772b6075a7cb50e0c9e7e92aff41183/app/src/main/java/com/theveloper/pixelplay/data/service/MusicService.kt#L92-L105
P1 Badge Expose custom command to controllers

MusicService handles CUSTOM_COMMAND_GET_POSITION in onCustomCommand, but the service never advertises this custom command in onConnect. Without adding it to the session’s available command group, MediaController.sendCustomCommand will return RESULT_ERROR_NOT_SUPPORTED and the progress polling in PlayerViewModel will never receive a position update. Add the command in onConnect when constructing the MediaSession so controllers are permitted to call it.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lostf1sh lostf1sh deleted the fix-bluetooth-progress-bar branch January 16, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant