[Feature Request] Support full Bluetooth controll on Android
Opened this issue · 4 comments
Describe the solution you'd like
When using the player on my android phone, the player only reacts to play/pause Bluetooth commands. E.g. skipping to the previous/next song is not supported. I would like to see this functionality added.
Additional context
- I am using Firefox as a browser on my Android.
- When I try controlling the player running in Firefox on a computer/Laptop, all Bluetooth commands work.
💡 Without being familiar with these topics, googling about this turned up this API: https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API. Maybe this is what needs to be adopted here?
Edit: Just realized you are already using the nexttrack
and previoustrack
API here, and according to this list they should work on Firefox Android. So not really sure what the issue is... 🤔
Hello,
yes. thank you for referring to the code. I was just about to post the same. mediasessions were already implemented while back.
But are you sure that FF on Android is able to process any commands? does it continue playing more than one song?
Issue is, that Audio Player is a JS player. And mobile devices do not process JS when the screen is locked.
On running FF in the background
Your question about FF being usable with locked screen surprised me a bit, since I already had listened full albums with locked screen. So I did some experimenting with different phones and this is what I found out:
- Apparently you need to exclude Firefox from battery saving modes and then it stays alive/handles media session commands even with a locked screen. This already was the case for me on my main phone, so I did not encounter any issues there.
Firefox vs Chrome
Regarding the media session commands in Firefox it is still weird though. When I use your player with Firefox, then the media panel in the notification bar looks like this:
👉 not much information and the only Button available (which can be triggered via bluetooth input) is play/pause.
When I run it with Chrome, the panel looks like this:
👉 more infos, displaying the album cover, additional buttons to skip back/forth in the track list which also work via bluetooth
Thoughts on the discrepancy
Looking at this Media Session API compatibility table, it seems to me like what you implemented should already work though. There is just one remark saying Firefox exposes the API, but does not provide a corresponding user-facing media control interface.
, so maybe this is the issue... I will try to get some clarification on this from the Mozilla Community and update here.
thank you for the ongoing input
@Rello I raised this with the Firefox Android team and it turned out that this is simply not fully implemented yet. Apparently they have an abandoned MR for it that they might pick up again.
So to my understanding your implementation would support this out of the box as soon as this is implemented on their side. Your call if you want to close this issue or leave it open as a reference.