ubuntu-touch icon indicating copy to clipboard operation
ubuntu-touch copied to clipboard

Feature Request - Add headset media button functionality

Open ruralelectrification opened this issue 6 years ago • 8 comments

Description of the feature

Add functionality for the media button on wired headsets. For clarity, this is the button on a headset that one can press to answer a call or pause/unpause media, and one can hold to end a call.

Bluetooth on UT (for me) has been pretty ropey, so I do not know if this media button functionality is missing for a comparable Bluetooth headset (Anyone know?). If it is missing, then similar functionality for Bluetooth headsets is also requested.

I found this about the way this is implemented in Android >>> https://developer.android.com/guide/topics/media-apps/mediabuttons

The use-case for this is obviously assisting in hands-free calling, and more importantly (for me!) the pausing and unpausing of media. Currently, if I need to stop playback quickly, I unplug the headset which pauses it. Plugging the headset back in and searching for the "play" button in the notification menu to resume playback is a less-than-ideal process.

Not a dev, but more than happy to do research for this. I just need some direction to know what I should be looking for/what is needed.

ruralelectrification avatar Jan 26 '19 00:01 ruralelectrification

This has been a long time requested feature even way abck to the Canonical days. I can't find if there's already an open issue about this UBports' repo. I think the issue is about how to capture the button events. Maybe no one has looked into it deeper for some time.

kugiigi avatar Jan 27 '19 15:01 kugiigi

On opo the headset button generates a KEY_MEDIA on /dev/input/event3. unity-system-compositor gets the key event from mir and changes or extends the power state (display goes or stays on).

For play/pause it could instead trigger an Mpris2 PlayPause dbus signal.

For pickup/hangup something similar might exist (but I don't know).

I have sort of a proof of concept here: https://github.com/wdehoog/ubports-misc/tree/master/gestures

wdehoog avatar Dec 24 '19 13:12 wdehoog

Can you please re-test this with latest devel? Media keys in music app should work at least.

Flohack74 avatar Aug 08 '22 16:08 Flohack74

On MX4 and BQ 4.5 running 2022-W45 this is not fixed. When the button is pressed, the screen turns on (if off). Media is not paused. Tested with the standard media player and Podbird. Additional info and testing on request.

Edit: Forgot to mention these are wired headphones (Sony MDR-EX15AP). Also, tested again with the music app on MX4 - same result.

eeveex avatar Nov 16 '22 10:11 eeveex

Xperia X RC

Cheap wired headset. When playing a song in music app pressing the media button (accept, stop call, just one button available on my headset) on my headset does ... nothing.

With my shokz Openrun bluetooth headset pressing the media button does: stop playing, resume playing. Double press does jump to the next song, triple press does jump back to the last song. So this is working as expected regarding music app.

The bt headset does not work with calls though. The media button there does quit a call, but no sound is heard and the mic is not being used.

Danfro avatar Nov 18 '22 16:11 Danfro

Tested on Pixel 3a with bluetooth media controls from Flipper Zero

Working

Calls

Both outgoing and incoming calls can be accepted and ended with a single click of the play/pause button.

https://user-images.githubusercontent.com/6209627/202759748-0a251dca-d753-46d0-b456-56fd13ff6c71.mov

https://user-images.githubusercontent.com/6209627/202757855-81f545a8-0f4c-4215-a93c-46d2759542e5.mov

Not working

Calls

There seems to be no way of declining an incoming call. I tried long pressing and double clicking the play/pause button, but that seems to only accept the call.

Media control

Playing/pausing a video doesn't work in the Media Player or YouTube in Morph

https://user-images.githubusercontent.com/6209627/202759024-5d7f565a-a1b2-4dee-ab00-6cd16fd6fe0d.mov

ilyakooo0 avatar Nov 18 '22 16:11 ilyakooo0

It worked on both 6T and FP4 using my father car, when using audio or mp3 I was able to stop and resume audio reproduction. On the contrary, I'm not able to end calls or make using the same buttons of the steering wheel

ivoxavier avatar Nov 18 '22 18:11 ivoxavier

Hi, I'd like to help test this if I can (if there is testing to be done). I'm on a Redmi 9 Pro, on the RC channel, and my cheap cable headphone buttons do nothing but turn on the screen (no volume control, no play/pause control).

GTimothy avatar Jan 15 '23 18:01 GTimothy