Open Bug 1473393 Opened 6 years ago Updated 1 year ago

"MediaNextTrack" and "MediaPrevTrack" not working on WebExtension

Categories

(WebExtensions :: General, defect, P3)

x86
Windows 10
defect

Tracking

(firefox62 affected, firefox63 affected)

Tracking Status
firefox62 --- affected
firefox63 --- affected

People

(Reporter: espinosajesus8, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
Build ID: 20180702164905

Steps to reproduce:

Create simple webextension to catch customizable commands from user. 
When trying to use MediaKeys specifically the keys "MediaNextTrack" and "MediaPrevTrack" don't work as expected.

Update some default shortcuts defined on the manifest.json to MediaKeys as the following:
browser.commands.update({
  name: "Shortcut name",
  shortcut: "MediaNextTrack"
});

Then log the name of the shortcut that receive the browser listener into the console.


Actual results:

The browser listen a "MediaPlayPause" and log always the name of "MediaPlayPause" into the console.


Expected results:

Should have log the name of "MediaNextTrack" or "MediaPrevTrack" instead of "MediaPlayPause".
Hi, Can you please upload the web extension to this bug report in order to test this issue with the same environment ?
Flags: needinfo?(espinosajesus8)
Hi, I'm on vacation and haven't a pc so I'm not able to upload the extension. However I can provide the GitHub link where I have the extension.

https://github.com/TsunDoge/spotify-hotkeys-firefox 

Providing more info: The extension allows the user to use customizable keyboard shortcuts on Spotify webplayer. A user has reported me that using the mentioned media keys don't work as expected.
Trying to reproduce the issue I mapped the keys and logged the name of the shortcut when the browser detect it and always print "MediaPlayPause"

Sorry for not being able to upload the extension.
Flags: needinfo?(espinosajesus8)
Hi TsunDoge, I downloaded the web extensions and it works great in spotify.. in Firefox versions 62.0b6 (64-bit) as well as 63.0a1 (2018-07-09), the only keys that aren't working are Alt+Shift+F for shuffle and ALT+SHIFT+B for playing the entire album.. and after i changed the default keys to different shortcuts, those worked as well, maybe we can try again with your extension when you will be able to upload it.

Also if you could download the latest version of Firefox Nightly from here https://nightly.mozilla.org/ and retest the problem it might help us as well.
Flags: needinfo?(espinosajesus8)
(In reply to Rares Doghi from comment #3)
> Hi TsunDoge, I downloaded the web extensions and it works great in spotify..
> in Firefox versions 62.0b6 (64-bit) as well as 63.0a1 (2018-07-09), the only
> keys that aren't working are Alt+Shift+F for shuffle and ALT+SHIFT+B for
> playing the entire album.. and after i changed the default keys to different
> shortcuts, those worked as well, maybe we can try again with your extension
> when you will be able to upload it.
> 
> Also if you could download the latest version of Firefox Nightly from here
> https://nightly.mozilla.org/ and retest the problem it might help us as well.

Hi Rares Doghi,
Sorry for the delay. As you suggested I donwloaded the Nightly version and deploy the extension with the webextension tool and unfortunately it does not work.

Besides seems I wasn't able to explain the bug itself. What it doesnt work is not the extension but the MediaKeys. I provide the extension that allows to customize the shortcuts but it can be tested with a simple webextension that catchs the "MediaNextTrack" and "MediaPrevTrack" from the manifest and verify that firefox does not emit that command and uses "MediaPlayPause" instead.

Can you please try again the extension with the "MediaNextTrack" and "MediaPrevTrack" commands and print the name of the commands that the browser send to the console?
Example: add the following line in the background.js script inside the runCommand function.
--> console.log("Command name: " + command); 

I also provide these links to the issues for more info. Hope I explained myself better.
https://github.com/TsunDoge/spotify-hotkeys-firefox/issues/7
https://github.com/piroor/webextensions-lib-shortcut-customize-ui/issues/10
Flags: needinfo?(espinosajesus8)
Hi, so i tried reproducing this issue using a keyboard that also has those media buttons and after i changed the shortcut keys to "MediaNextTrack" and "MediaPrevTrack" for next and previous I got the following results:

Clicking from the Spotify Extension using the mouse on each shortcut it will register the correct shortcut in the Browser Console and change the Next Track and Previous Track correctly as well as Shuffle and Pause.

Clicking from the Keyboard using the Media Keys the Actions are working correctly but in Browser console I'm only seeing "next" regardless of what action is performing like "Pause", "Previous" or "Stop".

I Used Nightly 63.0a1 (2018-07-15) and i have customized the shortcuts for this extension : https://github.com/TsunDoge/spotify-hotkeys-firefox.
Status: UNCONFIRMED → NEW
Component: Untriaged → Add-ons Manager
Ever confirmed: true
OS: Unspecified → Windows 10
Product: Firefox → Toolkit
Hardware: Unspecified → x86
Version: 62 Branch → Trunk
Flags: needinfo?(mstriemer)
I was unable to reproduce this on my Mac, but only because none of the media keys seem to work in Firefox or Chrome. I will try to reproduce this at home on my Windows PC another time.

It seems like we might not be able to support media keys on Mac, so maybe we'll need to update the documentation.
Component: Add-ons Manager → General
Product: Toolkit → WebExtensions
Priority: -- → P3

Came here because I have the exact same problem with the Spotify extension. Next and Prev keys work as Play/Pause

Oh. I think I see what the problem is. The WebExtension API uses the names MediaNextTrack/MediaPrevTrack, but Firefox calls these keys MediaTrackNext/MediaTrackPrevious: https://searchfox.org/mozilla-central/rev/7fd1c1c34923ece7ad8c822bee062dd0491d64dc/dom/events/KeyNameList.h#222-223. We probably just have to adjust the name we use internally.

Severity: normal → S3
Flags: needinfo?(mstriemer)
You need to log in before you can comment on or make changes to this bug.