polywock / globalSpeed

Web extension to set a default speed for video and audio
https://chrome.google.com/webstore/detail/global-speed-youtube-netf/jpbjcnkcffbooppibceonlgknpkniiff?hl=en
1.58k stars 178 forks source link

Issue with global keyboard shortcuts when using split screen in Microsoft Edge #414

Closed MuhammadAA777 closed 2 days ago

MuhammadAA777 commented 11 months ago

When using global keyboard shortcuts, most of them don't work by default when using split screen in Edge (neither in the browser, nor globally). To make them all work, it's necessary to manually click on the 'select preferred video for media hotkeys' button (for the video that's running in split screen) and only then, the shortcuts start working for the video that I'm running in split screen. This is only an issue when using split screen, as the media hotkeys work just fine when using normal tabs. Please address the issue, as being able to use global keyboard shortcuts in split screen mode is very useful, and it would be inconvenient to have to select each video as the preferred video for media hotkeys every time you want to control a video in split screen.

polywock commented 11 months ago

Hello. The Edge split screen feature introduced a lot of changes that aren't reflected in the extensions API. A few things I noticed investigating this issue.

  1. For the tabsAPI, Edge treats split screen as being a different tab entirely, even if visually it's part of the same tab. This is probably because Tab items represent a more traditional tab and only has one slot for URL, favicon.
  2. There doesn't seem to be any standardized way of checking if a Tab item is actually a right/bottom pane of a split screen tab. The only way I can think of right now involves using tabs.get on all tabs in the same window and if more than one are active at the same time, that will probably be a split tab.
  3. You are not able to query any split tabs using tabs.query. If you try to find all tabs in the current window, it will show the left panel of a split screen tab, but not the right one. Same if you try find "active" tabs, it will only show the left pane.
  4. Global shortcuts seem to work fine for controlling the left pane of a split screen tab.
  5. The right pane isn't reflected in Global Speed's popup menu at all. So if you press the pin icon, it will just control the left pane.

Until I find an efficient way of detecting if a "tab" is actually a split screen tab, and which is truly the active one, it will be hard to figure out a solution for this. For now, I recommend having the video on the left pane as it seems to still work. I will explore possible solutions.

MuhammadAA777 commented 11 months ago

I didn't realise that the problem only applies to the right pane of the split screen; that can be a useful workaround so thanks for pointing that out.

The right pane isn't reflected in Global Speed's popup menu at all. So if you press the pin icon, it will just control the left pane.

As mentioned in my original post, I am able to control the video in the right pane via global shortcuts after clicking on the 'select preferred video for media hotkeys' button (I'm using the stable version of Edge; not sure if that makes a difference), so Global Speed is able to detect the video that is playing in the right pane, and if you select that video as the preferred video for hotkeys, the video in the right pane can then be controlled via global shortcuts. Hence, the content in the right pane can also be controlled globally, but it requires that one extra step of clicking the select preferred video button.

polywock commented 11 months ago

Selecting the video also works for me. That's because the video is associated with a specific tab ID so Global Speed knows exactly where to send the shortcut action to. By pin, I meant the 📌 icon, which creates a separate context for a tab so that tab can have a separate speed.

The problem with the global shortcuts is that it uses the commands API, which only tells you the tab ID of the left pane. So the extension sends the action to that left-pane. To make it work for split screen, I will have to know if that tab id is part of a split screen, and which pane is actually truly selected. The solution itself is easy as I already worked out a method, the problem is doing as efficiently as possible.

MuhammadAA777 commented 11 months ago

Understood. This isn't really on topic, but it would be very useful if by default a video could be controlled via media hotkeys (when there's only one active video in the browser) from any other tab without having to select it as the preferred video for media hotkeys. I am specifically talking about when there is only one video being played in the browser. Naturally, when there are multiple videos running, it makes sense to have to select the preferred video for media hotkeys, but when it's only one video, we should be able to control it via the hotkeys from any background tab by default without having to select it first. That would be the ideal behaviour for the extension to have when only one video is running in a background tab.

polywock commented 11 months ago

I think I could add a flag for that. An option that will automatically select the last playing media element, even if it's on a separate tab. I probably won't make it a default setting as it's defies user expectations.

MuhammadAA777 commented 11 months ago

That sounds like it would be a very useful feature because usually the last playing element is the one that one wants to be able to control from any tab in the browser, so the extension automating this process would make things a lot simpler. Is it also possible for the extension to have some kind of option in the settings so that when there's only one active media element in the browser, it is selected as the preferred video for media hotkeys by default (then, when there are multiple elements, it can switch to manual selection)?

polywock commented 11 months ago

What do you consider an active media?

MuhammadAA777 commented 11 months ago

For example, once I've started playing a YouTube video, even if I've paused it, it still shows up in global speed's media list (from what I remember at least; the extension has sort of detected that media element and stored it in its memory), so I would consider that as an active media element and want to be able to continue to control that while using a different tab (pause/unpause it, go back/forward, increase/decrease speed, etc). Edit, I just checked, and a paused video only stays in GS's media list if I've selected it as the preferred video for media hotkeys. So if it gets auto selected as the preferred video for media hotkeys as soon as it starts playing, it can then be controlled via hotkeys from anywhere in the browser.

In any case, I suppose the option of auto selecting the last active media element that you mentioned would serve the purpose effectively enough.

MuhammadAA777 commented 9 months ago

I think I could add a flag for that. An option that will automatically select the last playing media element, even if it's on a separate tab. I probably won't make it a default setting as it's defies user expectations.

Hi. I was just wondering if there's any update regarding when the addition of this feature can be expected, as I feel it's definitely something that can improve the user experience.

polywock commented 9 months ago

I'm in a slight pickle regarding this. I've been working on porting Global Speed to Manifest V3, and it required a significant refactor. All Chrome extensions must be using Manifest V3 by June 2024. In the Manifest V3 version I fixed your issue by introducing a new feature to support it, but I cannot publish it yet because Manifest V3 doesn't fully support all the features Global Speed requires.

So my choices are...

  1. Re-fix your issue for the Manifest V2 version and publish that update. I'm slightly against this idea for various reasons. (1) I'm too lazy to re-write the feature for MV2 Global Speed. (2) I don't want to introduce new features to MV2 Global Speed.
  2. Wait it out until Manifest V3 supports what I need or I am forced to publish due to June 2024 deadline (with some features of Global Speed removed)
MuhammadAA777 commented 9 months ago

I'm in a slight pickle regarding this. I've been working on porting Global Speed to Manifest V3, and it required a significant refactor. All Chrome extensions must be using Manifest V3 by June 2024. In the Manifest V3 version I fixed your issue by introducing a new feature to support it, but I cannot publish it yet because Manifest V3 doesn't fully support all the features Global Speed requires.

So my choices are...

  1. Re-fix your issue for the Manifest V2 version and publish that update. I'm slightly against this idea for various reasons. (1) I'm too lazy to re-write the feature for MV2 Global Speed. (2) I don't want to introduce new features to MV2 Global Speed.
  2. Wait it out until Manifest V3 supports what I need or I am forced to publish due to June 2024 deadline (with some features of Global Speed removed)

Well, at least it's good to hear that you've got the feature figured out, and it sounds like it'll simply be a matter of time before it's eventually added. Btw, does this June deadline also apply to Edge addons? Since I'm an Edge user, I only use the version of the extension that is on the Edge addons website, not the Chrome webstore one.

polywock commented 9 months ago

does this June deadline also apply to Edge addons?

Yes, since Edge is based on Chromium, they're sticking with the same deadline as Chrome.