Automattic / Automattic/pocket-casts-android

Check if Android correctly handles play/pause for BT devices

Open
#149 5 comments 1 reaction 0 assignees View on GitHub
[Area] Playback [Priority] Low [Type] Bug Migrated
Dominant language
Kotlin
Stars
2.8k
Forks
308
Avg merge
1d 10h
Merged PRs (30d)
187

Description

User report:

```
I have a 2019 audi e-tron where I use android auto to play pocketcasts.

When I use youtube music, I'm able to pause and unpause the music with the steering wheel button. However, with pocketcasts, I can only pause it. It does not resume playing when I press the button again on the steering wheel; I have to resume playback by pressing a button on the screen.
```

Russell stated:

> I suspect what's happening here is that the button on the steering wheel always sends a pause event. On iOS we handle this like so:
> ```
> commandCenter.playCommand.addTarget { [weak self] _ -> MPRemoteCommandHandlerStatus in
> guard let strongSelf = self, let _ = strongSelf.currentEpisode() else { return .noActionableNowPlayingItem }
>
> if Settings.legacyBluetoothModeEnabled() {
> FileLog.shared.addMessage("Remote control: playCommand, treating as play (Legacy BT Mode is on)")
> if !strongSelf.playing() { strongSelf.play() }
> }
> else if let lastPlayTime = UserDefaults.standard.object(forKey: Constants.UserDefaults.lastPlayEvent) as? Date, fabs(lastPlayTime.timeIntervalSinceNow) < 10.seconds {
> // iOS will sometimes issue two remotePlay commands, so if it's been less than 10 seconds since the last one, just play don't try to playPause
> FileLog.shared.addMessage("Remote control: playCommand, treating as play")
> if !strongSelf.playing() { strongSelf.play() }
> }
> else {
> if strongSelf.playingOverAirplay() {
> // during handoff iOS will call us to play even if we already are, so honour that here
> FileLog.shared.addMessage("Remote control: playCommand, treating as play because playing over AirPlay")
> if !strongSelf.playing() { strongSelf.play() }
> }
> else {
> // we hook play up to play/pause because that's how some headphones/car stereos do it instead of sending distinct play/pause events
> FileLog.shared.addMessage("Remote control: playCommand, treating as playPause")
> strongSelf.playPause()
> }
> }
> ```
>
> I realise this is for the play command on iOS, but it might be worth checking the Android app to see if it doesn't something similar to handle this case?

Contributor guide

Open the contributing guide

Research direction

No Android file or test is named. Start by locating the Android Bluetooth or media-session remote-control entry point, then compare its play/pause handling with the iOS behavior quoted here and reproduce the reported steering-wheel interaction; done means the button can pause and resume Pocket Casts playback.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.