carlin-q-scott / browser-media-players

Control interface for a variety of web based media players
Mozilla Public License 2.0
58 stars 8 forks source link

Not working on Linux with awesomeWM #4

Open timvisee opened 5 years ago

timvisee commented 5 years ago

The extension does not seem to be working for my configuration. I'm using a Linux machine running Ubuntu 18.04 with the awesomeWM display manager (so no, that isn't GNOME). Along with that, I'm using an Ergodox Infinity keyboard configured with a MediaPlay key. I believe this is the standard play/pause key, but I'm not entirely sure. The key does work for playing/pausing music in Rhythmbox. Anyhow, I don't believe the keyboard is the problem.

Pressing the MediaPlay button does not trigger anything within the browser, neither when I focus a Deezer page for example. I there a possibility to fix this? What does the add-on depend on when using it with GNOME?

If my keyboard configuration might be relevant, here it is: https://github.com/timvisee/dotfiles/tree/e44a6e579843874212819d425d7df6e6131faa9b/ergodox

Here are my general system specifications, if relevant: neofetch

carlin-q-scott commented 5 years ago

You'll need to use the MediaPlayPause event, not MediaPlay. Firefox currently only supports the former event at this time.

timvisee commented 5 years ago

First of all, thank you for the quick answer.

I believe that is the key that I've bound, it is called MediaPlayPause or PL/PS in my configurator at least. I named it MediaPlay as this website is reporting that name when I'm pressing the button. Interestingly enough, the website reports MediaPause when holding Shift at the same time.

This is the output from xev when pressing (and releasing) the key I'm talking about:

KeyPress event, serial 39, synthetic NO, window 0x4800001,
    root 0x2c0, subw 0x0, time 2673506689, (366,544), root:(1646,564),
    state 0x2000, keycode 172 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 40, synthetic NO, window 0x4800001,
    root 0x2c0, subw 0x0, time 2673506902, (366,544), root:(1646,564),
    state 0x2000, keycode 172 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

This is the output from two other keys also used for media playback (which also aren't working):

KeyPress event, serial 41, synthetic NO, window 0x4800001,
    root 0x2c0, subw 0x0, time 2673604987, (832,710), root:(2112,730),
    state 0x2000, keycode 215 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
    XKeysymToKeycode returns keycode: 172
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 42, synthetic NO, window 0x4800001,
    root 0x2c0, subw 0x0, time 2673605130, (832,710), root:(2112,730),
    state 0x2000, keycode 215 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
    XKeysymToKeycode returns keycode: 172
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 42, synthetic NO, window 0x4800001,
    root 0x2c0, subw 0x0, time 2673605911, (832,710), root:(2112,730),
    state 0x2000, keycode 127 (keysym 0xff13, Pause), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 42, synthetic NO, window 0x4800001,
    root 0x2c0, subw 0x0, time 2673606040, (832,710), root:(2112,730),
    state 0x2000, keycode 127 (keysym 0xff13, Pause), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Or do you still believe the keyboard is sending the wrong keycode? I don't seem to have more options available, thus I might have to modify the keyboard firmware if it's impossible to register these other keycodes in Firefox.

carlin-q-scott commented 5 years ago

@gmelikov Can you comment on this? Am I right in thinking that we need to map XF86AudioPlay to MediaPlayPause in the browser, or is this is similar to your advice on the other issue to remove xfce bindings?

carlin-q-scott commented 5 years ago

Hmm, nevermind. Firefox only recognizes PlayPause so that must not be it... I hope.

So this is probably similar to carlin-q-scott/browser-media-keys#132

gmelikov commented 5 years ago

@carlin-q-scott does this addon work with the same code as media-keys? If so, @timvisee please see https://github.com/carlin-q-scott/browser-media-keys#support-on-linux , you need to install libxcb-keysyms1 lib to work.

timvisee commented 5 years ago

@gmelikov Thanks for the suggestion. Installing xcb-util-keysyms (on Manjaro Linux this time) didn't solve the issue however. I did reboot, that didn't help either.

What I found interesting is that even when Firefox is focused and is showing a YouTube or Deezer page, the play key still doesn't do anything. I'm sure Firefox is able to detect these keys (of course, only wen focused), as the keyboard tester is showing these keys are triggered as I've said. By the way, manually invoking these keys using xdotool doesn't work either.

@carlin-q-scott The other thread you've mentioned talks about XFCE not handling media keys. I'm using awesomeWM which is not handling these keys for sure (awesomeWM is quite bare bones). Is it required that the window manager somehow processes these keys to pass a play/pause signal to Firefox. I thought having a keyboard that has media keys would be enough.

Please let me know if there's a way I can easily debug where the problem in the chain lies.

carlin-q-scott commented 5 years ago

I've released v2.1 which allows you to set custom key combos for the media events. Let me know if that helps at all with your issue @timvisee https://addons.mozilla.org/en-US/firefox/addon/media-keys/versions/?page=1#version-2.1.0

timvisee commented 5 years ago

@carlin-q-scott Thank you for the effort! I can't figure out how to configure these keys though. Are you sure the feature is indeed included in the 2.1 release?

This is what I'm seeing on the add-on preferences page: Add-on preferences screenshot

carlin-q-scott commented 5 years ago

@timvisee Thanks for the fast response!

It should look like this:

firefox_2018-10-11_11-50-27

I'm hiding the commands div for Opera/Chrome since they manage commands differently. This is the html I'm using for that:

    <style>
        label { width: 12ch; }
        @media (-webkit-min-device-pixel-ratio:0) {
            div#commandsDiv { display: none}
        }
    </style>

Can you check if window.matchMedia('-webkit-min-device-pixel-ratio:0').matches returns false in your browser console? That's the same statement expressed as javascript.

timvisee commented 5 years ago

@carlin-q-scott Yes, it does return false (and I also restarted the browser with no effect):

Expression

I did attempt to inspect the panel to see whether the div is available (and indeed hidden), but I can't go deeper than the stack element which seems to wrap all of the plugin preference controls.

carlin-q-scott commented 5 years ago

I fixed a bug in the options hiding code with v2.1.1 that just went live. Maybe it'll work now. I'm not sure since it seemed to work just fine on the release version of FF.

gmelikov commented 5 years ago

I can see these settings, firefox 62 on Linux.

timvisee commented 5 years ago

Nope, version 2.1.1 didn't fix it either.

Note that I'm running Firefox Nightly. This is what about:support shows: about:support

carlin-q-scott commented 5 years ago

Ok, looks like nightly added support for the webkit specific property I was checking. I've fixed it in master but will release the fix later

carlin-q-scott commented 5 years ago

@timvisee Version 2.1.3 is now live with support for command options in firefox nightly.

timvisee commented 5 years ago

@carlin-q-scott Thank you for the update. I'm now indeed able to set custom keys. The button I'm pressing on my keyboard is indeed called MediaPlay which I've now configured for the Play/Pause action.

Pressing this key on other pages such as YouTube or Deezer doesn't do anything though. Changing the key to for example a doesn't either. Not when the browser is focused, nor when it isn't.

carlin-q-scott commented 5 years ago

@timvisee I probably should be reporting errors for keys that cannot be used. After looking at Firefox's code base I've found that they don't support MediaPlay as a command shortcut and I doubt they allow a letter by itself. ctrl+shift+a might work. I used ctrl+shift+arrow for testing the command mappings. Up for play/pause, down for stop, right/left for next/previous.

timvisee commented 5 years ago

@carlin-q-scott Changing the binding to one of your suggested keys doesn't work either. I'm able to set the key, but no action is triggered when pressing it on any page.

It's weird. Something seems to be really broken :disappointed:

carlin-q-scott commented 5 years ago

What does the browser console say after you save your new command bindings? I just tested on your same version of Ubuntu and Firefox, and I found that MediaPlay does indeed show up when I press my PlayPause button. I also noticed that saving anything invalid for any of the commands causes the extension to stop working. Simply saving again with valid command bindings fixes it.

Could you try saving this html file to your computer in a folder names "tests" and opening it with firefox for testing? It supports the next and play/pause commands: https://raw.githubusercontent.com/carlin-q-scott/browser-media-players/bfc752da40611020a3208ce92168c02721cd44d3/tests/pandora.com.html . I want to rule out the possibility that it's somehow the particular site, although youtube works fine in all of my testing.

timvisee commented 5 years ago

@carlin-q-scott The console doesn't show any message when specifying a binding, nor when saving. I don't see anything either in the console when hitting the specified binding on a website such as YouTube.

I did check the pandora.html file. When pressing the media button (or any other button I define in the plugin's settings), nothing happens. Only when I click the second item (play / pause) with my mouse, the current state on the page changes. This doesn't affect any media that is currently playing though.

I just thought about the Vimium plugin, which I have installed to use Vim bindings throughout my browser. I thought that I might hijack the bindings. After disabling the Vimium plugin it still didn't work though.

carlin-q-scott commented 5 years ago

@timvisee Did you restart the browser after disabling the other extension?

Mozilla has this to say about command conflicts:

If a key combination is already used by the browser (for example, "Ctrl+P"), or by an existing add-on, then you can't override it. You will be allowed to define it, but your event handler will not be called when the user enters it.

That would explain why there are no errors in the browser console.

timvisee commented 5 years ago

@carlin-q-scott I believe I did not. I will give that a try for sure.

By the way, I've also attempted to use it on a Windows machine, which didn't work either. Same keyboard, same key, same browser configuration but a different machine.