Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth controls #90

Open
bigcattus opened this issue Jul 6, 2022 · 9 comments
Open

Bluetooth controls #90

bigcattus opened this issue Jul 6, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@bigcattus
Copy link

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
Copy link
Owner

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
Copy link
Author

bigcattus commented Jul 7, 2022

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 rbackhouse self-assigned this Jul 7, 2022
@rbackhouse rbackhouse added the enhancement New feature or request label Jul 7, 2022
@rbackhouse
Copy link
Owner

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
Copy link
Author

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

@macmpi
Copy link

macmpi commented Jul 16, 2022

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

  • using mpris (makes the link between mpd and bluez, or
  • through acpid, and handling AVRCP key presses from input device (same key codes than keyboard media keys)

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

@bigcattus
Copy link
Author

bigcattus commented Jul 16, 2022

@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
Copy link

macmpi commented Jul 16, 2022

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
Copy link

macmpi commented Jul 17, 2022

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
Copy link
Author

Interesting, thanks, will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants