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

Open
wants to merge 4 commits into
base: release-10.10.z
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { MediaError } from 'types/mediaError';
import { getMediaError } from 'utils/mediaError';
import { toApi } from 'utils/jellyfin-apiclient/compat';
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind.js';
import browser from 'scripts/browser.js';
import { bindSkipSegment } from './skipsegment.ts';

const UNLIMITED_ITEMS = -1;
Expand Down Expand Up @@ -3687,9 +3686,7 @@ export class PlaybackManager {
}

bindMediaSegmentManager(self);
if (!browser.tv && !browser.xboxOne && !browser.ps4) {
this._skipSegment = bindSkipSegment(self);
}
this._skipSegment = bindSkipSegment(self);
}

getCurrentPlayer() {
Expand Down
20 changes: 16 additions & 4 deletions src/components/playback/skipsegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import './skipbutton.scss';
import dom from 'scripts/dom';
import globalize from 'lib/globalize';
import * as userSettings from 'scripts/settings/userSettings';
import focusManager from 'components/focusManager';
import layoutManager from 'components/layoutManager';

interface ShowOptions {
animate?: boolean;
keep?: boolean;
focus?: boolean;
}

class SkipSegment extends PlaybackSubscriber {
private skipElement: HTMLButtonElement | undefined;
private skipElement: HTMLButtonElement | null | undefined;
private currentSegment: MediaSegmentDto | null | undefined;
private hideTimeout: ReturnType<typeof setTimeout> | null | undefined;

Expand Down Expand Up @@ -50,7 +53,7 @@ class SkipSegment extends PlaybackSubscriber {
}
});

document.body.appendChild(elem);
document.querySelector('#videoOsdPage')?.appendChild(elem);
this.skipElement = elem;
}
}
Expand Down Expand Up @@ -78,6 +81,10 @@ class SkipSegment extends PlaybackSubscriber {

void elem.offsetWidth;

if (options.focus) {
focusManager.focus(elem);
}

requestAnimationFrame(() => {
elem.classList.remove('skip-button-hidden');

Expand Down Expand Up @@ -116,7 +123,8 @@ class SkipSegment extends PlaybackSubscriber {
if (isOpen) {
this.showSkipButton({
animate: false,
keep: true
keep: true,
focus: false
});
} else if (!this.hideTimeout) {
this.hideSkipButton();
Expand All @@ -140,7 +148,10 @@ class SkipSegment extends PlaybackSubscriber {

this.setButtonText();

this.showSkipButton({ animate: true });
this.showSkipButton({
animate: true,
focus: layoutManager.tv
});
}
}

Expand All @@ -165,6 +176,7 @@ class SkipSegment extends PlaybackSubscriber {
onPlaybackStop() {
this.currentSegment = null;
this.hideSkipButton();
this.skipElement = null;
Events.off(document, EventType.SHOW_VIDEO_OSD, this.onOsdChanged);
}
}
Expand Down
Loading