ogplayer 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Keyboard shortcuts for `<og-player>` — the map from `KeyboardEvent.key` to
3
+ * a player action, kept DOM-free so the resolution is unit-testable.
4
+ * Desktop keyboards only; TV remotes are a separate concern and are not
5
+ * wired through here.
6
+ *
7
+ * The default map is the one viewers already know from the big video sites:
8
+ * Space/K play-pause, ←/→ and J/L seek by the player's seek increment,
9
+ * ↑/↓ volume, M mute, F fullscreen, C subtitles, 0–9 jump to 0–90 % (VOD),
10
+ * Home/End start/end (live edge on live), Esc leaves fullscreen.
11
+ */
12
+ export type OGKeyAction = "playPause" | "seekBackward" | "seekForward" | "volumeUp" | "volumeDown" | "toggleMute" | "toggleFullscreen" | "exitFullscreen" | "toggleSubtitles" | "seekToStart" | "seekToEnd" | "seekToPercent";
13
+ /** Per-key overrides merged over {@link DEFAULT_KEYMAP}: `null` removes a
14
+ * key, an action adds or remaps one. Keys are `KeyboardEvent.key` values;
15
+ * single characters are matched case-insensitively. */
16
+ export type OGKeymap = Partial<Record<string, OGKeyAction | null>>;
17
+ export declare const DEFAULT_KEYMAP: Readonly<Record<string, OGKeyAction>>;
18
+ /** Single characters compare case-insensitively ("M" and "m" are one key);
19
+ * named keys ("ArrowLeft", "Home") are used as they come. */
20
+ export declare function normalizeKey(key: string): string;
21
+ /** The effective map: defaults, then the host's overrides on top. Never
22
+ * mutates {@link DEFAULT_KEYMAP}. */
23
+ export declare function mergeKeymap(overrides?: OGKeymap): Record<string, OGKeyAction>;
24
+ export interface KeyLike {
25
+ key: string;
26
+ ctrlKey?: boolean;
27
+ metaKey?: boolean;
28
+ altKey?: boolean;
29
+ }
30
+ export interface ResolvedKey {
31
+ action: OGKeyAction;
32
+ /** 0–9 for `seekToPercent` (the digit key that was pressed). */
33
+ digit?: number;
34
+ }
35
+ /**
36
+ * Which action, if any, a key press means under `keymap`. Returns `null` for
37
+ * keys that are not ours — including every modifier chord (Ctrl/Cmd/Alt),
38
+ * which stays with the browser and the page. `seekToPercent` only resolves
39
+ * from a digit key, because the digit is the target.
40
+ */
41
+ export declare function resolveKeyAction(e: KeyLike, keymap: Record<string, OGKeyAction>): ResolvedKey | null;
@@ -1,6 +1,7 @@
1
1
  import type { OGPlayer } from "../core/player.js";
2
2
  import type { OGPlayerError } from "../core/types.js";
3
3
  import { type OGControlColors, type OGControlDimens } from "./tokens.js";
4
+ import { type OGKeymap } from "./keymap.js";
4
5
  /** A host-supplied icon button rendered left of the (future) cast position —
5
6
  * icon-only, max 8, part of the chrome (mirrors Android/iOS `CustomAction`). */
6
7
  export interface CustomAction {
@@ -101,6 +102,18 @@ export interface OGUIConfig {
101
102
  /** Extra inline CSS for the card (same contract as `titleStyle`), e.g.
102
103
  * "background:#F6C445E6;color:#131313;font-family:Georgia,serif". */
103
104
  upNextStyle?: string;
105
+ /** Keyboard shortcuts while the player has focus (default true): Space/K
106
+ * play-pause, ←/→ and J/L seek by the seek increment, ↑/↓ volume, M mute,
107
+ * F fullscreen, C subtitles on/off, 0–9 jump to 0–90 % (VOD), Home/End
108
+ * start/end (live edge on live), Esc leaves fullscreen. Seek keys obey
109
+ * the live rules and stay inert during ads. `false` = the element handles
110
+ * no keys at all (not even Space) — the host owns the keyboard. */
111
+ keyboardShortcuts: boolean;
112
+ /** Per-key overrides merged over the default map: `{ m: null }` removes
113
+ * mute, `{ p: "playPause" }` adds a key, `{ ArrowUp: "seekForward" }`
114
+ * remaps one. Keys are KeyboardEvent.key values; letters are
115
+ * case-insensitive. Unmapped keys pass through to the page. */
116
+ keymap?: OGKeymap;
104
117
  }
105
118
  export declare const defaultUIConfig: OGUIConfig;
106
119
  /** Every control flag off — headless chrome in one call (mobile parity:
@@ -143,6 +156,8 @@ export declare class OGPlayerElement extends HTMLElement {
143
156
  constructor();
144
157
  get player(): OGPlayer | null;
145
158
  set player(p: OGPlayer | null);
159
+ /** Subtitle track the C key switched off, restored on the next press. */
160
+ private lastTextTrackId;
146
161
  get config(): OGUIConfig;
147
162
  set config(c: Partial<OGUIConfig>);
148
163
  connectedCallback(): void;
@@ -202,6 +217,11 @@ export declare class OGPlayerElement extends HTMLElement {
202
217
  * a "starts in fullscreen" flow calls this from its start button. */
203
218
  enterFullscreen(): Promise<void>;
204
219
  exitFullscreen(): void;
220
+ /** One keyboard shortcut → one player action. Seek keys follow the live
221
+ * rules (nothing on edge-locked LIVE, window-bound on LIVE_DVR, End = the
222
+ * live edge) and stay inert during ads; volume, mute and fullscreen work
223
+ * everywhere. Actions that change what the viewer sees raise the chrome. */
224
+ private runKeyAction;
205
225
  private toggleFullscreen;
206
226
  private detach;
207
227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ogplayer",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "OGPlayer video player for the browser — an <og-player> web component with HLS, DRM (Widevine, PlayReady, FairPlay), Google IMA ads, playlists and themeable controls.",
5
5
  "type": "module",
6
6
  "main": "./dist/ogplayer.js",