Automattic / pocket-casts-android

Pocket Casts Android 🎧
https://forums.pocketcasts.com
Mozilla Public License 2.0
2.57k stars 215 forks source link

Pixel Buds skip back not working on Samsung device #1624

Closed mchowning closed 4 months ago

mchowning commented 9 months ago

Description

On my Samsung A13 device, triple-tapping the headphone button on my usb-c wired pixel buds does not do the skip back action. Instead, it does a skip forward and then a play/pause action.

I do not have this issue when using my usb-c wired pixel buds with a Pixel 6 Pro running Android 14.

I do not have this issue when using a Tribit bluetooth speaker with my Samsung A13 running Android 13.

I have reproduced this behavior on 7.45, 7.50, and the most recent 7.54-rc-3 build, so this is not a recent regression from an app change on our end, and it is not fixed by the recent fix we did for Pixel Buds on Pixel phones (which was included in 7.54-rc-3.

Step-by-step reproduction instructions

  1. Start playing an episode
  2. Connect usb-c pixel buds (might also be true with wireless pixel buds, but I haven't tested that)
  3. Triple tap the headphone button
  4. Observe that the app does the skip forward action and then pauses.
  5. Triple tap the headphone button again
  6. Observe that the app does the skip forward action again and then resumes playback.

Screenshots or screen recording

In this clip I follow the above test steps: first starting playback manually, then doing a triple click that skips and pauses playback, followed by a second triple click that skips and resumes playback.

https://github.com/Automattic/pocket-casts-android/assets/4656348/977de1f9-030d-4e5d-8a70-f63e0ad7d157

Did you search for existing bug reports?

Device, Operating system, and Pocket Casts app version

Samsung A13 running Android 13 Pocket Casts 7.45, 7.50, 7.54-rc-3 usb-c pixel buds

mchowning commented 9 months ago

If I log the media events using these changes on the code for 7.54-rc-3, with Pixel buds where the triple tap doesn't work I see:

15:34:48.369  I  TEST123, KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_MEDIA_PLAY_PAUSE, ... }
15:34:48.369  I  TEST123, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PLAY_PAUSE, ... }
15:34:48.647  I  TEST123, KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_MEDIA_PLAY_PAUSE, ... }
15:34:48.647  I  TEST123, onSkipToNext
15:34:48.649  I  TEST123, adding command to queue: skip forwards
15:34:48.651  I  TEST123, executing queued command: skip forwards
15:34:48.659  I  TEST123, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PLAY_PAUSE, ... }
15:34:48.857  I  TEST123, KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_MEDIA_PLAY_PAUSE, ... }
15:34:48.858  I  TEST123, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PLAY_PAUSE, ... }
15:34:49.158  I  TEST123, onPause
15:34:49.160  I  TEST123, adding command to queue: pause
15:34:49.162  I  TEST123, executing queued command: pause

If I connect a Bluetooth speaker and triple tap the play button (which successfully skips back) the events look very different:

15:35:58.222  I  TEST123, KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_MEDIA_PREVIOUS, ... }
15:35:58.222  I  TEST123, handleMediaButtonTripleTap
15:35:58.227  I  TEST123, onSkipToPrevious
15:35:58.227  I  TEST123, adding command to queue: skip backwards
15:35:58.230  I  TEST123, executing queued command: skip backwards
15:35:58.245  I  TEST123, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_MEDIA_PREVIOUS,  ... }

Adding a breakpoint to the onSkipToNext and onSkipToPrevious calls confirmed that when the skip improperly goes forward, the call is coming from the MediaSessionCompat class in the library and is not being called directly by our app. By contrast, when using other Bluetooth speakers and the call correctly goes backwards, we're making the call to onSkipToPrevious when we detect the KEYCODE_MEDIA_PREVIOUS KeyEvent.

mchowning commented 9 months ago

I did some testing on some other apps just for comparison, and on my Samsung A13 with wired usb-c pixel buds, I found that on most apps (Castbox, Google Podcasts, Podbean, Spotify) neither skip forward nor skip back worked. There were two apps where they both worked though (Youtube Music and AntennaPod), so it seems like we can improve our handling here.

yaelirub commented 9 months ago

@mchowning , should this issue be closed?

mchowning commented 9 months ago

This is still an issue. The other Pixel Buds fix did not address this (I actually discovered this while testing that).

I'll be interested to see if anyone else is experiencing this because as far as I know we haven't gotten any support inquiries about this specific problem (skip forward working back, but skip-back causing a skip-forward+pause).

yaelirub commented 9 months ago

I just responded to a review yesterday about this issue. I will share a link to the review in the channel.

mebarbosa commented 4 months ago

I am closing this one since we don't have more reports related to this issue. We believe this PR fixed it.