-
-
Notifications
You must be signed in to change notification settings - Fork 881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add keyboard shortcut to toggle mute on expando videos #5500
Conversation
893e0bc
to
35de74f
Compare
|
Don't think we need a test for this as its pretty straight forward behaviour. |
This clashes with the ModMail keyboard shortcut: https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/master/lib/modules/keyboardNav.js#L733-L739. M requires goMode to be enabled before actioning Modmail, With it turned off this PR would work, however with it enabled it errors out. |
Any suggestions on a solution? Should this shortcut only be allowed/enabled when goMode is enabled to avoid the clash? Or should it use another key by default? I'm hesitant to have it use shift-m/ctrl-m, as the ideal interaction is using J and K to scroll through posts and M to mute/unmute the current post, and adding a modifier kind of messes with that flow since shift-J would jump down a page instead if the user messes up their button order. |
Updated to 'o' as that does not appear to be used at all. |
@@ -1172,6 +1180,11 @@ function imageMove(deltaX, deltaY) { | |||
ShowImages.move(mostVisible, deltaX, deltaY); | |||
} | |||
|
|||
function videoToggleMute() { | |||
const mostVisible = getMostVisibleElementInThingByQuery('.res-video-container', ASSERT); | |||
ShowImages.toggleMute(mostVisible); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be preferable to inline toggleMute
. Also we might as well allow toggling mute on any video
objects, not only RES's.
Probably something like this:
const video = downcast(getMostVisibleElementInThingByQuery('video', ASSERT), 'video');
video.muted = !video.muted;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do the mute-any-video handling in my initial impl but ran into a few hurdles involving how RES determines which entity is in focus; I wasn't too sure how to handle it, so if you have any further details that would be appreciated.
Also, would there be any benefit to leaving toggleMute in ShowImages rather than pulling it out to here? I was under the impression (from the rest of the file) that we tried to limit the amount of logic happening in keyboardNav.js and instead defer logic to the ShowImages module/etc, which is why my impl has it like that, but if it isn't needed, I'll pull the toggleMute logic up to here.
If I remember correctly, the user will be prompted whether |
Given that 'o' is unused entirely, it might just be fine to leave it on 'o' and let users rebind it to 'm' if they want. On a QWERTY layout it also lines up a little better for usage with J/K and [] for navigation, though it really isn't that much different from 'm' in that regard. Let me know which I should go with. |
Thanks! |
Ah, I was still in the process of seeing if I could get it working for any video element. I'll open up a followup PR for that, as well as for inlining instead of calling ShowImages if you think that's necessary as well. |
@larsjohnsen @benmcgarry I could have sworn I set the keybind for this to 79 ( |
Relevant issue: N/A
Tested in browser: Chrome
This adds a keyboardNav bind (default 'm') to toggle mute/unmute on the current most visible video expando.