polimediaupv / paella-core

Paella Player core library
Educational Community License v2.0
20 stars 15 forks source link

Make it possible to avoid the keyboard shortcut warning with multiple Paella instances #354

Open LukasKalbertodt opened 7 months ago

LukasKalbertodt commented 7 months ago

In Tobira, we get this warning for a while now when multiple Paella players are on one page (and also in other situations due to some reasons):

paella-core - Warning: Warning: more than one paella player instance with enabled shortcut plugins.
paella-core - Warning: Check your code to ensure that only one instance of paella player registers keyboard shortcut plugins.

The warning makes sense to me: if multiple players are present, it's not clear what player should be controlled by the keyboard shortcut. However, I don't see a way to avoid this warning as the keyboard shortcuts are always initialized, as far as I can tell:

The warning is emitted in loadKeyShortcutPlugins. That function is called unconditionally in preLoadPlayer. And that in turn is called unconditionally in loadManifest. So there is no way to tell Paella to not initialize keyboard shortcuts, right? But that's what is needed to remove this warning and properly handle shortcuts.

ferserc1 commented 5 months ago

I agree that it should be possible to not show the message, but what I would like is to never show the message, and to make the keyboard shortcuts work even if you have more than one player.

At the moment what I've thought of is to capture the events depending on the visibility of the player, taking into account the scroll of the page. If there is more than one player visible in the scroll, the events would be captured by the first player that is visible. It's not a perfect solution, but I think it's better than what we have now.

Any other ideas would be welcome, for the moment I can't think of anything better.