-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don’t bind to keyevents of media keys when browser support mediaSession #5526
Don’t bind to keyevents of media keys when browser support mediaSession #5526
Conversation
These events are already handled by MediaSession. On some operating systems, like Windows, the browser will send both the MediaSession event and the keydown event to the webpage, causing the event to be handled twice and resulting in issues.
Cloudflare Pages deployment
|
This needs to be tested on TV with keyboard connected. |
If the TVs really work that bad with that then this should be TV only, having both listeners will clearly conflicts with each other. |
We could do something like this: const hasMediaSession = 'mediaSession' in navigator;
...
case 'MediaPlayPause':
if (!hasMediaSession) inputManager.handleCommand('playpause');
break; But I have no idea if modern TVs have |
Even if they do, is it really reliable is also questionable. Do we have the double event issue for TV yet? If we don't then probably one of the event handler is not really working for the TVs, but which one is unknown. |
I'm sure var i, keyCode = {}, supportedKeys;
supportedKeys = tizen.tvinputdevice.getSupportedKeys();
for (i = 0; i < supportedKeys.length; i++) {
keyCode[supportedKeys[i].name] = supportedKeys[i].code;
}
if(keyCode.hasOwnProperty("ChannelUp")) {
tizen.tvinputdevice.registerKey("ChannelUp");
}
window.addEventListener("keydown", function(keyEvent) {
// identify the key by the numeric code from the keyEvent
if(keyEvent.keyCode === keyCode.ChannelUp) {
console.log("The CHANNEL UP was pressed");
}
}); After a quick look, there is no MediaSession API. |
@GeorgeH005 Can you do me a favor for this as well? Can you test if webOS have MediaSession and is its MediaSession reliable? So that we can have some level of confidence for two major smart TV platforms. |
@gnattu MediaSession does seem to exist in the webOS app runtime. Couldn't test its reliability right now, but I'll try to in the following days. The remote also doesn't have any media keys, so I can't test if they bind to those events or not. |
Updated to make the compatibility better. Now it only binds media keys on TV and browsers not having mediaSession. Should work good enough and cover most use cases. |
Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com>
Quality Gate passedIssues Measures |
Don’t bind to keyevents of media keys when browser support mediaSession Original-merge: 6da3dd7 Merged-by: thornbill <thornbill@users.noreply.github.com> Backported-by: Joshua M. Boniface <joshua@boniface.me>
These events are already handled by MediaSession. On some operating systems, like Windows, the browser will send both the MediaSession event and the keydown event to the webpage, causing the event to be handled twice and resulting in issues.
Changes
Remove media key binding in keyboardNavigation
Issues
Fixes #5523