Skip to content

Conversation

@LetItRock
Copy link

@LetItRock LetItRock commented Jan 3, 2026

Summary

This PR fixes #2564 and several issues with Android media controls and improves the playback event handling system. It also updates the example app to handle playback events correctly and adds Ruby 3.4 compatibility.

Changes

Android/Kotlin Core Changes

  1. Fixed CustomCommandButton capability mapping (CustomCommandButton.kt)

    • Fixed swapped NEXT/PREVIOUS capabilities (PREVIOUS was using SKIP_TO_NEXT, NEXT was using SKIP_TO_PREVIOUS)
    • This ensures the correct capabilities are associated with the right button actions
  2. Added setPlayWhenReady override (BaseAudioPlayer.kt)

    • Added override to properly emit PLAY/PAUSE events when playWhenReady state changes
    • Ensures external state changes are properly tracked and reported
  3. Enhanced Media3 notification action handling (MusicService.kt)

    • Added handling for custom notification button clicks (NEXT, PREVIOUS, JUMP_FORWARD, JUMP_BACKWARD) via Media3's notification UI
    • Works on all Android versions by handling ACTION_CUSTOM_NOTIFICATION_ACTION in onStartCommand
    • Added Media3 custom notification action constants
  4. Improved media button event handling (MusicService.kt)

    • Split play/pause media button handling to emit separate BUTTON_PLAY and BUTTON_PAUSE events instead of combined BUTTON_PLAY_PAUSE
    • Checks current playback state before emitting the appropriate event
    • Provides more granular control and better state tracking

Example App Changes

  1. Fixed RemotePlayPause event handler (PlaybackService.ts)

    • Updated to check playback state before toggling play/pause
    • Prevents incorrect state transitions and improves reliability
  2. Ruby 3.4 compatibility (kconv_patch.rb, Gemfile)

    • Added monkey patch for kconv compatibility (removed from Ruby 3.4 standard library)
    • Updated Gemfile to load the compatibility patch
    • Constrained cocoapods version to < 1.17.0 to avoid compatibility issues
    • Added .ruby-version file
  3. Build configuration updates

    • Updated Gemfile.lock and Podfile.lock with latest dependencies
    • Updated iOS Xcode project configuration

Testing

  • Verified play, pause, seek, previous, next buttons work correctly in media notification
  • Verified play/pause events are emitted correctly
  • Verified custom notification actions work on Android simulator
  • Verified example app playback service handles events correctly
  • Verified Ruby 3.4 compatibility patch works

Video

Screen.Recording.2026-01-03.at.14.mp4

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.

Notification completely broken on MIUI 13 / Android 12 - buttons unresponsive and in wrong order

2 participants