rbackhouse / MaximumMPD

React Native based MPD Client for iOS and Android
MIT License
47 stars 5 forks source link

Bluetooth controls #90

Open bigcattus opened 2 years ago

bigcattus commented 2 years ago

I noticed that Maximum MPD does not react to bluetooth playback controls from bluetooth headphones (pause/play/next/prev). This does not work in all other MPD clients that I tried so far (mpdroid, malp, others). Thanks.

rbackhouse commented 2 years ago

I'm not sure I understand the use-case. MaximumMPD does not support streaming, its a controller for MPD servers, so why would connected bluetooth headphone be used to control playback ?

bigcattus commented 2 years ago

I have a local MPD server (running in termux). MaximumMPD controls the playback using MPD socket. I hoped that it could proxy bluetooth events so that PLAY/STOP receiver events could be translated into MPD events. I guess that code piece is missing. This does not look like a bug but rather a missing feature that would be great to have. I chatted with people on termux irc; it looks like I am not the only one looking for that feature. It's a pain to use this setup in the car if there are no bluetooth controls in the app.

MALP does seem to have relevant code that does not work for some reason. I don't program for Android, and I didn't try to debug this.

Thank you for releasing the app, it looks and works great.

Edit: I think BT event handling code is in application/background/BackgroundService.java in MALP; git@gitlab.com:gateship-one/malp.git

rbackhouse commented 2 years ago

This seems a little similar to the support in iOS for the "Now Playing" widget (both in the phone and on the watch) The control events from it are picked up by the app for basic music actions (play, pause, stop, prev, next etc).

I can look into what I can do in android around listening for these bluetooth headphone actions

bigcattus commented 2 years ago

That would be awesome, and thank you for considering that.

macmpi commented 2 years ago

@bigcattus it's best to handle on server side actually, with very simple shell scripts. 2 main methods:

I'm doing the latter on my tiny-radioCD server if you want to look at it (dev branch more current).

bigcattus commented 2 years ago

@macmpi Thanks for the suggestion. The problem is that my mpd runs on an android device, not on linux. I run it from termux (https://termux.com/). On linux, I can use xbindkeys to capture keyboard events (e.g. XF86AudioPlay).

If there were a way to get callbacks in termux on bluetooth events, that would definitely solve the problem for me.

macmpi commented 2 years ago

I've not used android for a while and I'm not sure how much termux is isolated from underlying Linux when not rooted.

You can try to check a few things, like installing evtest and check whether AVRCP input device shows-up when headset is connected and if keys events flow in when pressed (in that case capturing keyboard events should work).

Also you may check how much you can interact with bluez stack through dbus under termux: in that case mpris might be a workable solution if you can install mpris bluez component/service (maybe it's already there), and mpris client for mpd.

I'm afraid we now are a bit off-topic for maximumMPD issues though... Good luck.

macmpi commented 2 years ago

Reading this on termux page:

Ready to scale up. Connect a Bluetooth keyboard and hook up your device to an external display if you need to - Termux supports keyboard shortcuts and has full mouse support.

It very much seems termux exposes bluetooth keyboards, so they are likely expose AVRCP keys similarly: chances are you will see them with evtest (or xbindkeys): those key events are same as those of media keys on std keyboards.

bigcattus commented 2 years ago

Interesting, thanks, will look into this.