OxygenCobalt / Auxio

A simple, rational music player for android
GNU General Public License v3.0
2.04k stars 134 forks source link

Gadgetbridge media control is not working #62

Closed Golbinex closed 2 years ago

Golbinex commented 2 years ago

Describe the bug/crash:

Gadgetbridge is a FOSS app for controlling smart watches and bands. It also supports controlling media playback from watches. Most players are supported and play/pause, forward/rewind actions on the gadget are working. However on Auxio I can only see the name of played track and change volume. Auxio is not visible in Gadgetbridge music player list.

Steps To Reproduce the bug/crash:

  1. Play a track on Auxio
  2. Go to music section on smart watch/band
  3. Try to pause track

    Logs/Stack Traces:

Screenshots:

Screenshot_20220104-085912_Gadgetbridge_1

Phone Information:

Android 12

Due Diligence:

OxygenCobalt commented 2 years ago

Do you use an Android Wear smartwatch or an external smartwatch, like pebble? If it's the former, then I haven't added Android Wear support yet. If it's the latter, then theres something wrong with Auxio's MediaSession implementation again.

Golbinex commented 2 years ago

I use Mi Band 6, so an external smart band.

OxygenCobalt commented 2 years ago

Probably a MediaSession issue again then, my implementation is a broken mess. I'll lump it in with #52 and address it eventually. What's curious is that the app doesn't even show up in the menu. I have zero idea how that is happening, which makes me wonder if it's some other issue.

OxygenCobalt commented 2 years ago

@Golbinex I actually think I figured out the issue. Gadgetbridge queries for BroadcastReciever instances in the app manifest that handle the Intent.ACTION_MEDIA_BUTTON intent. Auxio does not do expose such, as it instead relies on the media session to intercept media button events.

I doubt I can fix this issue on my end, as my only options are reintroducing #20 or having every media button press result in it calling twice. I would recommend reporting this as an issue to the Gadgetbridge developers. Their code should be able to handle apps that only expose a MediaSession instead of using an implementation straight out of 2011.

For more info, this is the offending piece of code.

OxygenCobalt commented 2 years ago

@Golbinex @foldfree

I found a way around this issue. The media library does actually expose it's BroadcastReceiver under androidx.media.session.MediaButtonReceiver. So, I believe it's possible to hack around this issue by simply exposing that library class in my manifest.

Can you guys try this debug APK? [Rename the extension] I don't have a smartwatch, so I'm only able to confirm that GadgetBridge detects the media button intent and not if it can use it.

Auxio_GadgetBridge.zip

foldfree commented 2 years ago

I tried multiple times and the app crash when i press either pause or next, previous. I shared the log below

https://pastebin.com/7N4FZ6wZ

PS: I'm not sure if thoses logs are relevant, let me know if I need to do something else.

OxygenCobalt commented 2 years ago

@foldfree I think I may have gotten the intent structure wrong. Try this APK?

Auxio_GadgetBridge2.zip

foldfree commented 2 years ago

@foldfree I think I may have gotten the intent structure wrong. Try this APK?

Auxio_GadgetBridge2.zip

Thanks, it works perfect, tried all the buttons.

OxygenCobalt commented 2 years ago

Fantastic. Let me clean up this implementation and I'll close the issue.

foldfree commented 2 years ago

Media control is not responsive with the latest release (2.3.0) I checked back with 2.2.2 and it worked so something broke it after that release.

OxygenCobalt commented 2 years ago

Oh, you have got to be kidding me. I removed the BroadcastReciever code (while keeping the manifest entry) assuming that the MediaSession had some code somewhere that would handle it normally, and that my own code was largely redundant. I was completely wrong, it turns out. I'll write a fix.

OxygenCobalt commented 2 years ago

If you want, heres a 2.3.0* build with the fix in. I'm only doing this since this fix will likely arrive in a 2.4.0 (which could be a ways away with the changes I'm working on)

Auxio_2.3.0_GadgetBridgeFix.zip