Skip to content
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

Enable TV Support for 'Ask to Skip' #6295

Merged
merged 11 commits into from
Dec 29, 2024

Conversation

viown
Copy link
Member

@viown viown commented Nov 4, 2024

Changes
Enables TV Support for the skip button

Issues

@jellyfin-bot
Copy link
Collaborator

jellyfin-bot commented Nov 4, 2024

Cloudflare Pages deployment

Latest commit 5f10569
Status ✅ Deployed!
Preview URL https://de6e4d52.jellyfin-web.pages.dev
Type 🔀 Preview

View build logs

@viown viown marked this pull request as ready for review November 6, 2024 17:28
@viown viown requested a review from a team as a code owner November 6, 2024 17:28
@viown viown added the needs testing This PR requires additional testing label Nov 6, 2024
@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Nov 11, 2024

  1. I think we should focus the skip button (on show) if OSD is hidden.
  2. Found bug: _skipElement is not reattached on the second video playback. Separate PR.
    1. Start video playback.
    2. Wait for the Skip button to appear.
    3. Stop playback (return to the library/item).
    4. Resume video playback. Button is not attached to the DOM.
  3. We should use emby-button to highlight the focus state. There is no (native) focus indication in webOS 1.2.

@viown
Copy link
Member Author

viown commented Nov 11, 2024

I think we should focus the skip button (on show) if OSD is hidden.

I agree, it's not intuitive to have to click up two times when the button appears.

Found bug: _skipElement is not reattached on the second video playback. Separate PR.

Thanks! This is an issue with just this PR because videoOsdPage is unmounted when playback stops and it originally only created the button once in the body and re-used it on second playback.

@viown viown added the stable backport Backport into the next stable release label Dec 4, 2024
@dmitrylyzo
Copy link
Contributor

@viown Could you try changing the skip button to emby-button?

We should use emby-button to highlight the focus state. There is no (native) focus indication in webOS 1.2.

Alternatively, we can add focus and hover (#6364) styles. But emby-button is already styled.

Also, don't focus the skip button when the OSD is visible.

@viown
Copy link
Member Author

viown commented Dec 5, 2024

Yes, to do this I will have to move the button to the OSD template, which is probably what I should've done to begin with.

Also, the button should not focus when the OSD is visible. Do you see different results in your testing?

@dmitrylyzo
Copy link
Contributor

Do you see different results in your testing?

Yes, it grabs the focus when I navigate the playback control buttons (to keep the OSD visible).

With this clip: https://github.com/user-attachments/assets/95ac625f-a41d-46d1-9125-1f6c4356552a

  1. Switch to the TV display mode.
  2. Enable Ask to Skip for Intro and Outro only.
  3. Start that clip.
  4. Seek to the middle.
  5. Use the Left/Right buttons to move between the playback control buttons (to keep OSD visible).
  6. When `Outro' begins, the skip button grabs the focus.

@viown
Copy link
Member Author

viown commented Dec 5, 2024

Updated to use emby-button. Your mentioned issue should be fixed. I also noticed that the button would cause the video to pause on click (just this PR), so that was fixed as well.

Given how complex this PR became, I wonder if it still makes sense for a 10.10.z release?

@dmitrylyzo
Copy link
Contributor

  1. this.skipElement seems to become invalid when the next episode starts playing.
    Start playlist with 2 video items with chapters.
    Wait for the skip button to appear.
    Click Next track.
    The skip button doesn't appear unless you refresh the web page.

  2. This code pauses playback when using Enter on the skip button (in the TV mode).
    As a quick fix:

if (e.target.tagName !== 'BUTTON') {
    playbackManager.playPause(currentPlayer);
}

We are losing the ability to pause using the `OK' button on the TV remote control, so we need to rethink the skip button focus logic and/or UI.

Given how complex this PR became, I wonder if it still makes sense for a 10.10.z release?

Alternatively, we could try moving the skip button back from the video OSD and block the focus change by checking the current document.activeElement. Don't change the focus if activeElement is a valid focusable element.
The problem is that activeElement can be undefined, body or the last focused element when out of focus when hiding an element. So it should be checked with care, but isCurrentlyFocusable is probably sufficient.

Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor notes. Not tested yet.

src/components/playback/skipsegment.ts Show resolved Hide resolved
src/components/playback/skipsegment.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost fine.

  1. There's a problem with CustomElements (see below). Major issue.
  2. The focus is lost after we hide the skip button.
    This is a global problem. If we don't find a good concept for changing focus after hiding the current element, I think we can leave it to the next version - the user can use Back to hide the OSD and show it again using the navigation keys.

src/components/playback/skipsegment.ts Outdated Show resolved Hide resolved
@viown
Copy link
Member Author

viown commented Dec 16, 2024

Yeah, I noticed that focus was lost after clicking the button, but wasn't sure what the best way to go about it was.

Since skipping will summon the OSD panel, we might be able to change the focus to the play/pause button. Adding focusManager.focus(document.body.querySelector('.btnPause')); after this line seems to work (with checks for TV layout).

Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do with focus (focus loss can happen not only on the video OSD), but we can probably fix that later. As workaround: users can hide the OSD with Back/Escape buttons and regain focus when it reappears.

@rlauuzo
Copy link
Contributor

rlauuzo commented Dec 29, 2024

To address the focus issue, you can make the following changes:

  1. Update lines 1254-1256 in index.js to handle the Enter key differently based on the element triggering the event:

    case 'Enter':
        showOsd(e.target.classList.contains('skip-button') ? btnPlayPause : undefined);
        break;
  2. Prevent the skip button from losing focus by modifying lines 357-359:

    if (document.activeElement && !document.activeElement.classList.contains('skip-button')) {
        document.activeElement.blur();
    }

@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Dec 29, 2024

  1. Update lines 1254-1256 in index.js to handle the Enter key differently based on the element triggering the event:

I think it would be better to restore it here:

} else if (currentVisibleMenu === 'osd' && focusElement && !layoutManager.mobile) {
_focus(focusElement);
}

We need to remove focusElement from the condition. If !focusElement and document.activeElement is not focusable, use btnPause as the focus element.

 } else if (currentVisibleMenu === 'osd' && !layoutManager.mobile) {
    if (!focusElement && (!document.activeElement || !focusManager.isCurrentlyFocusable(document.activeElement)) {
        focusElement = osdBottomElement.querySelector('.btnPause');
    }
    _focus(focusElement); 
 }

Not tested.

Iirc, we also need to add range input (playback progress bar) as focusable element to isCurrentlyFocusable. The skip button grabs focus from it.

2. Prevent the skip button from losing focus by modifying lines 357-359:

We should check that document.activeElement is a child of osdBottomElement.

@thornbill thornbill added enhancement Improve existing functionality or small fixes and removed needs testing This PR requires additional testing labels Dec 29, 2024
@thornbill thornbill added this to the v10.10.4 milestone Dec 29, 2024
@thornbill thornbill merged commit 26df03b into jellyfin:release-10.10.z Dec 29, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing functionality or small fixes stable backport Backport into the next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants