We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

bluetooth headset buttons for Spotify (android)

asked 2018-01-18 19:21:44 +0300

ray-ven gravatar image

On my Sailfish X i can skip and pause Spotify (android) via the homescreen buttons which didn't work with Jolla 1, so I think, it shouldn't be a big deal to make my bluetooth headset buttons work with spotify. This would be great! Doesn anybody know how to do that?

Thank you Ray

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-01-18 21:25:20 +0300

Kao gravatar image

Unfortunately headphone buttons (wired and bluetooth) currently do not work for Android apps, only native ones. Also see this question.

edit flag offensive delete publish link more

Comments

I know, but bluetooth buttons work with native apps - and the sailfish homescreen audio buttons work with android apps, so it can't be that difficult to add one or two lines of code somewhere to make that happen. I'm quite sure someone has found a way

ray-ven ( 2018-01-18 21:34:31 +0300 )edit
2

To expand on Kao's answer :

  • Sailfish uses BlueZ and has a full support for everything bluetooth.
  • Android normally uses Bluedroid for bluetooth-stuff
  • There's currently no BlueZ-to-Bluedroid translation layer in the Alien-Dalvik Android compatibility layer used in Sailfish OS.
  • Because of that, NO ANDROID APP can EVER SEE a bluetooth device directly. They only see the standard interfaces. None of your apps can see your headset directly.
  • But bluez and pulseaudio support it as a standard audio output, and the Spotify app simply sees an audio output to which to play without ever knowing that there's Bluetooth involved somewhere.

Regarding the buttons:

  • Bluez does support buttons as any other input device, and they'll show up as inputs on the system (as buttons on any keyboard - regardless of BT transport).
  • Currently Android apps see inputs as a standard keyboard without even knowing that there's BT involved in the way (that's how you can use a BT keyboard to type messages in WhatsApp).
  • Currently, Spotify is getting your button presses as generic keypress. The fact that it's not responding means that it's not reacting to these specific keys (if you had plugged a USB keyboard in a OTG port, Spotify would have similarly ignored the media keys).

To make the button work :

  • it's not just 1 or 2 lines of code somewhere. You'd need in theory something to forward BlueZ into the BlueDroid inside the Android world of Alien-Dalvik (complex).
  • The closest thing to a simple hack is to check if there are some keyboard key codes that Spotify does actually recognize (even if it was keypresses on a wired keyboard), and try to find a way to remap the bluetooth buttons to that specific key presses (by fumbling around with the keyboard layouts - I'm not sure of the exact details, I'm more used to layout used by Xorg on desktop, than by Lipstick/Wayland on Jolla).
DrYak ( 2018-01-22 13:27:23 +0300 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2018-01-18 19:21:44 +0300

Seen: 419 times

Last updated: Jan 18 '18