YePpHa / YouTubeCenter

YouTube Center is a userscript designed to expand the functionality of YouTube. It includes the ability to download the video you're watching, auto selecting your preferred video quality and much more.
MIT License
2.89k stars 519 forks source link

YouTube player shortcuts on page inconsistent #953

Open harveyadcock opened 9 years ago

harveyadcock commented 9 years ago

I've noticed a bug in YTCenter where the shortcut buttons (space for pause/play etc.) don't always work on the page. They work fine when the video is the active part of the page, but when other parts are, some of them woe but some don't sometimes. So the ones I mainly use are forward/backward arrows for short skipping, spacebar for pausing/playing and 'f' for full screen. This last one is the one that seems to sometimes work when the actual player isn't selected but sometimes doesn't.

I'm using YTC 2.1.5 on Safari 7.0.6 for Mac.

Yonezpt commented 9 years ago

From what I have seen so far the youtube shortcuts will only work if you make the player "active" and by active I mean you have to click on the player to kinda "awake" the shortcut listener. Once you click somewhere else outside the player then the shortcuts become inactive.

I have tested this with the youtube center addon disabled and the behavior is still the same.

For example, when I open a video and press "F" nothing happens, but if I touch the controlbar black area and then hit "F" now the player enters fullscreen. If I click outside the player then no shortcut works.

What this means is that this isn't a problem with the youtube center addon -as far as I could see- it's just how youtube works.

It is possible to extend the area of the shortcut listener to expand beyond the player to the entire page, for example, and that way everytime you open a video the shortcuts will always work, but that is a feature that I don't think YePpHa has implemented.

harveyadcock commented 9 years ago

This is default youtube behaviour, but with YTC there is an option to extend the control to the entire page under Player -> Shortcuts I think (not at a computer with it installed) called something like extend shortcuts to entire page.

This seems to always work for the pause/play shortcut and some others (at least for me) but often the 'f' key isn't being listened for, which is a bug when the controls are turned on.

Yonezpt commented 9 years ago

@harveyadcock You are correct, now I checked in my computer and it does have that feature (wasn't aware of it before).

I tested it and the pause/play spacebar shortcut is working as well as the left/right arrow for skipping, but the F key doesn't send the player to fullscreen nor do the up/down arrow keys change the volume. If anything, those are the only ones that aren't working properly.

By the way, this is with the youtube center developer version 394, not with youtube center 2.1.5

harveyadcock commented 9 years ago

Yeah, that's what I've noticed after more testing, but I could've sworn the f key occasionally worked despite the player not being selected. I might be losing it though...

YePpHa commented 9 years ago

It's not possible to make YouTube Center make the flash player go into fullscreen. It is possible to make the HTML5 player go into fullscreen mode when the F key is pressed. I will add a listener for the fullscreen shortcut, but it will only work on the HTML5 player. I can also add the volume listener, but I'm not sure if it's smart and if I should just wait to add that until I remake the shortcut feature in YouTube Center.

Yonezpt commented 9 years ago

@YePpHa For the annoying case of the flash limitations regarding this subject, wouldn't it be best -if possible- to set the embed element as active as soon as the page is loaded and whenever the user is not utilizing any text/input box?

This way there is no need to add extra event listeners and be limited by the few that work.

YePpHa commented 9 years ago

@Yonezpt I can try to look into it.

Yonezpt commented 9 years ago

@YePpHa I have been trying to find some way to make the suggested "hack" less ugly, but the only way I could find was to add the

wmode="opaque"

to the embed and then

yt.player.getPlayerByElement(playerid).focus()

Of course we will also need to re-activate the focus when the user clicks somewhere outside the element unless it is an input/text box, a simple click listener>ytplayer.focus() should do the trick

document.addEventListener('click',function(){
    var aEtN = document.activeElement.tagName;
    if(!(aEtN === 'EMBED' || aEtN === 'INPUT' || aEtN === 'OBJECT' || aEtN === 'TEXTAREA')){
        yt.player.getPlayerByElement(playerid).focus();
    }
})

I do not include the button exclusion because buttons remain active after they have been pressed, ruining the ability to continue using player shortcuts outside the embed element.

From what I could find there is no other way besides this one so I thought I would let you know before you loose too much time with something that isn't a big priority at this time.

YePpHa commented 9 years ago

@Yonezpt Seems like the correct way to do it.

Yonezpt commented 9 years ago

@YePpHa Just tried with the other wmode values and it only works with opaque and transparent, so remember to take into account that because you have wmode options as well in Player > Flash mode

If the user selects a value that isn't opaque or transparent and enables youtube page shortcuts it might cause a conflict, or one of the options might just not work.