31

I'm using Firefox in version 39.0. My keyboard has Media Keys and I want to use them for controlling sites like Soundcloud, Youtube, etc.

Is that possible?

firefox version

media keys

0

5 Answers 5

18
+50

The Media Keys add-on does not work in Firefox version 57, because the developers have decided to remake Firefox into a Chrome clone. For November 2017, they have announced their intention to drop in Firefox 57 their current add-on format, now called "Legacy", in favor of WebExtensions, which in plain English are very similar to Google Chrome extensions.

This will in theory open most of the Chrome Store to Firefox users, but will invalidate all, and I do mean all, current add-ons whose developers will not convert in time to WebExtensions.

One can already see the problem in Firefox 56 by opening the Add-ons tool. The add-ons that will not work in version 57 are marked by a yellow LEGACY notice :

image1

I have 46 add-ons in Firefox with which I have created the environment that is just right for me. All of them, except only one, are marked as legacy. The problem is much more general and extensive than you think.

Some possible solutions are listed below :

  • Ask the developers of your add-ons to make the effort of converting to WebExtensions.

  • Firefox 57 will include a "find similar extension" tool which might help to find replacement add-ons.

  • Abandon Firefox in favor of Chrome (I'm sure that a large percentage of Firefox users will follow this route).

  • Turn off updates and stay with Firefox 56 forever - not a real solution. One can also use here Firefox Portable.

  • Switch to Firefox ESR which will continue in version 56 until June 26, 2018, in the hope that someone will come up until then with a solution for running legacy add-ons in Firefox 57. This is not really much different from the above solution, except that critical updates will not be blocked.

  • Switch to Pale Moon, or Waterfox, both forked from Firefox, although not all add-ons are compatible.

None of these solutions is perfect, but I don't know of a better one at the moment. I think that the Firefox developers made a very stupid decision which will cost them a hefty chunk of their already eroding market share, but they are not asking for anybody's advice.


Another solution would be to use Chrome extensions in Firefox 57. The add-on Chrome Store Foxified already allows this.

From the article How many Chrome extensions will run in Firefox :

Mozilla's Andy McKay decided to find out in November 2016. He parsed the Chrome store sitemap and got 100,000 extensions, apps and themes out of it which he analyzed to find out how many of them will run in Firefox.

According to his findings, about 76% of Chrome extensions of the sample size will run in Firefox. The remaining extensions either miss one or more APIs, one or more permissions, or one or more manifest.

I have found the Chrome extension Streamkeys which according to its author does everything you asked for. However, not having Firefox 57, I don't know if it will work in it.

References :


A very light-weight solution for all browsers and versions, makes use of the following observations:

  • Some media keys are handled by the operating system, especially the volume keys
  • Most media players have hotkeys with the same functionality as the keyboard Media keys

Specifically for youtube, a list of the hotkeys can be found in the article 30+ YouTube Keyboard Shortcuts You Need to Know. Some of the ones corresponding to the keyboard media keys are:

Spacebar - Pause/Play video (player focus required)
K key - Pause/Play video (doesn’t require focus)
(Arrow key up) - Turn up volume 5%
(Arrow key down) - Turn down volume 5%
Ctrl+ - Move to next video (only in playlist)
Ctrl+ - Move to previous video (only in playlist)

These keyboard's media keys can be mapped to these keys using AutoHotkey. A list of AutoHotkey key-names is found in the article List of Keys, Mouse Buttons, and Joystick Controls.

An example of a AutoHotkey script for Youtube is:

SetTitleMatchMode, 2        ; match anywhere in window's title
#ifWinActive YouTube        ; only if window title contains YouTube
Media_Next:: Send ^{Right}  ; Next Track - ctrl+right-arrow
Media_Prev:: Send ^{Left}   ; Previous Track - ctrl+left-arrow
Media_Play_Pause::          ; Stop/Start - Spacebar
Media_Stop:: Send {Space}

The above script is completely untested, as my keyboard does not have these keys.

6
  • 1
    At least I'm not the only one unhappy with FF. Good answer, UVed. As for what I've done. I'm still on vista, so I was stuck with 51 ESR, now that looks like a good thing.
    – David
    Oct 19, 2017 at 13:39
  • @David: Myself I'm now on Firefox ESR 52.4.1, equivalent to FF56 and with the security updates from FF57. This gives me 8 more months to find a permanent solution.
    – harrymc
    Oct 19, 2017 at 14:36
  • I have found that FF ESR has problems with some addons which are unable to save their settings, example LastPass. Also the ESR version while based on FF56 is strangely named version 52, but because of this some addons refuse to work saying that the required Firefox version is at least 55. For these reasons I have moved to Waterfox, with which I'm very pleased.
    – harrymc
    Nov 4, 2017 at 16:12
  • Thanks, I apdated the AutoJotkey script to linux using xdotools
    – gwenzek
    Nov 17, 2017 at 10:49
  • 3
    Don't blame this on the extension developers. The API in FF57 (And Chrome) is severely crippled due to ridiculous omissions/shortcomings/crippling by Google (and now Mozilla). Decent: password managers, session managers, context menu managers, and download managers are now impossible. The Chrome equivalents are pale, user-hostile mockeries of what was once available on FF. Jan 1, 2018 at 17:38
17

Media Keys

Yes it is possible! For this download Media Keys from addons.mozilla.org. This tool adds a media key event listener to Firefox and makes it possible to use:

  • Play/Pause
  • Next
  • Previous
  • Stop

on every supported music/video site.

Issue

For some reason the media keys are only working if Firefox is the active window (occured on Windows 10). Also add-on currently does not work with Firefox 57+.

0
7

Linux (D-Bus) solution

Just leaving this here for the next person that will be in the situation I was half an hour ago. After searching around a bit I found this document linked from the Mozilla bugtracker, and it turns out that the latest version of Firefox support the MPRIS interface over D-Bus, which means that after messing around a bit with d-feet I managed to achieve my desired results!

Using i3 under Arch, I successfully set up hardware key play-pause for firefox by:

  1. Setting media.hardwaremediakeys.enabled to true on the about:config page
  2. Installing playerctl for sending d-bus commands (sudo pacman -S playerctl)
  3. Binding the play-pause key to the desired action
    (bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause)

ps.: I also recommend increasing the value of media.mediacontrol.stopcontrol.timer.ms on the about:config page, because by default you can only restart playback in the next 60 seconds after you paused. Increasing it to 1000000000 milliseconds from the default 60000 will give you around 11.5 days. :P

2
  • Hi, I've been playing with this too, the past few days, and I wrote a blogpost on the subject: work.lisk.in/2020/05/06/linux-media-control.html Thanks a lot for the link to the Firefox Media Control Documentation, I didn't find that one and it explains some issues that I found, like the media.mediacontrol.stopcontrol.timer.ms thing, so I added it to the text just now. May 6, 2020 at 20:47
  • I'm glad it helped! :) That document was not easy to find for me either, but it contains lots of valuable information! It's weird that sometimes these useful sources of information are hidden in a way that you need to dig really deep to get them. Anyway, luckily I have managed to stumble upon it in a discussion on the bug tracker after searching for tons of related keywords. I've just read some parts of your blog post, but I really like it, seems to be well researched and written!
    – Isti115
    May 6, 2020 at 22:44
6
+400

Currently the Firefox commands API does not support media keys nor global keys.

Until these issues are fixed by Mozilla, you can use Chromium with the Streamkeys extension.

2
1

Windows solution, similar is just the first step posted by @Isti115

Setting media.hardwaremediakeys.enabled to true on the about:config page The default was disabled here for some reason. Using Firefox 80, should work also around the 70s.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .