@ngxsp/core 0.1.0 → 0.2.1

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.
Files changed (65) hide show
  1. package/commands.d.ts +40 -0
  2. package/config/default-config.d.ts +34 -0
  3. package/domain/audio-identification-routine.d.ts +47 -0
  4. package/domain/audio-identification.d.ts +78 -0
  5. package/domain/audio-library.d.ts +59 -0
  6. package/domain/audio-metadata-harmony.d.ts +29 -0
  7. package/domain/device-playback.d.ts +40 -0
  8. package/domain/media-item.d.ts +22 -0
  9. package/domain/media-library-model.d.ts +75 -0
  10. package/domain/media-source.d.ts +115 -0
  11. package/domain/queue.d.ts +12 -0
  12. package/domain/remote-playback.d.ts +82 -0
  13. package/domain/ringtone.d.ts +46 -0
  14. package/domain/shake.d.ts +55 -0
  15. package/domain/vault.d.ts +55 -0
  16. package/engine/capability-report.d.ts +35 -0
  17. package/engine/engine-factory.d.ts +19 -0
  18. package/engine/engine-profile.d.ts +27 -0
  19. package/engine/native.engine.d.ts +23 -0
  20. package/engine/native.factory.d.ts +2 -0
  21. package/engine/playback-capabilities.d.ts +29 -0
  22. package/engine/playback-engine.d.ts +44 -0
  23. package/engine/remote-playback.engine.d.ts +77 -0
  24. package/engine/types.d.ts +15 -0
  25. package/events/event-bus.d.ts +15 -0
  26. package/facade/player-facade.d.ts +125 -0
  27. package/index.d.ts +60 -2491
  28. package/online/acoustid.d.ts +29 -0
  29. package/online/cast-v2.d.ts +62 -0
  30. package/online/dlna-renderer.d.ts +19 -0
  31. package/online/dlna.d.ts +48 -0
  32. package/online/internet-archive.d.ts +105 -0
  33. package/online/jellyfin.d.ts +24 -0
  34. package/online/lyrics.d.ts +69 -0
  35. package/online/md5.d.ts +5 -0
  36. package/online/mdns.d.ts +61 -0
  37. package/online/media-cache.d.ts +61 -0
  38. package/online/musicbrainz.d.ts +41 -0
  39. package/online/online-http.d.ts +10 -0
  40. package/online/playback-transfer.d.ts +106 -0
  41. package/online/radio-browser.d.ts +42 -0
  42. package/online/subsonic.d.ts +16 -0
  43. package/online/upnp.d.ts +30 -0
  44. package/online/webdav.d.ts +21 -0
  45. package/online/xml-text.d.ts +19 -0
  46. package/package.json +1 -1
  47. package/plugins/ads/ssai.plugin.d.ts +14 -0
  48. package/plugins/metadata/metadata.types.d.ts +28 -0
  49. package/plugins/metadata/providers/local-metadata.provider.d.ts +11 -0
  50. package/plugins/plugin.d.ts +20 -0
  51. package/plugins/progress/progress.plugin.d.ts +10 -0
  52. package/plugins/resilience/resilience.plugin.d.ts +12 -0
  53. package/plugins/subtitles/providers/local-subtitle.provider.d.ts +9 -0
  54. package/plugins/subtitles/subtitle-file.d.ts +14 -0
  55. package/plugins/subtitles/subtitles.types.d.ts +22 -0
  56. package/ports/http.port.d.ts +3 -0
  57. package/ports/log.port.d.ts +12 -0
  58. package/ports/ports.d.ts +14 -0
  59. package/ports/storage.port.d.ts +11 -0
  60. package/ports/telemetry.port.d.ts +7 -0
  61. package/remote-config/remote-config.d.ts +8 -0
  62. package/telemetry/telemetry.types.d.ts +11 -0
  63. package/types.d.ts +345 -0
  64. package/utils/cache-store.d.ts +12 -0
  65. package/index.d.cts +0 -2491
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Cutting a piece of a track to use as a ringtone.
3
+ *
4
+ * The piece is taken from where the listener is: they were listening to the part they want, and
5
+ * asking them to find it again in a waveform is asking them to do the work twice. So the start
6
+ * is the playhead, the length is a choice between a few, and what comes out is a real file.
7
+ *
8
+ * Both edges are faded. A ringtone cut straight out of the middle of a track starts with a click
9
+ * and ends with one, which is the difference between something made and something taken.
10
+ */
11
+ /** How long a ringtone may be. Android accepts more; a phone that rings for half a minute is enough. */
12
+ export declare const RINGTONE_MAX_SEC = 30;
13
+ /** Long enough not to click, short enough not to be heard as a fade. */
14
+ export declare const RINGTONE_FADE_SEC = 0.05;
15
+ export interface RingtoneSegment {
16
+ startSec: number;
17
+ lengthSec: number;
18
+ }
19
+ /**
20
+ * Where the piece starts and how long it runs, kept inside the track.
21
+ *
22
+ * A playhead near the end would give a piece that runs off it, so the start slides back to make
23
+ * room; a track shorter than the length asked for simply gives all of itself.
24
+ */
25
+ export declare function ringtoneSegment(options: {
26
+ positionSec: number;
27
+ trackDurationSec: number;
28
+ lengthSec: number;
29
+ }): RingtoneSegment;
30
+ /**
31
+ * Fades both edges in place, so the piece does not begin or end on a click.
32
+ *
33
+ * A piece too short to hold two fades gets shorter ones rather than none: the click is what is
34
+ * being removed, and half a fade removes it just as well.
35
+ */
36
+ export declare function fadeEdges(channels: Float32Array[], sampleRate: number, fadeSec?: number): void;
37
+ /**
38
+ * Writes audio as a WAV file: 16-bit PCM, the one encoding a page can produce on its own.
39
+ *
40
+ * It is not small, and it is not meant to be kept — it is what is handed to the system, which
41
+ * stores a ringtone however it likes. What matters is that no library has to be shipped to make
42
+ * one, and that every platform reads it.
43
+ */
44
+ export declare function encodeWav(channels: Float32Array[], sampleRate: number): ArrayBuffer;
45
+ /** A file name from a track's title: what a viewer will look for in their files. */
46
+ export declare function ringtoneFileName(title: string, extension?: string): string;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Shaking the device, read from its accelerometer.
3
+ *
4
+ * A shake is not one movement but several: the hand throws the device one way and pulls it back,
5
+ * and does it again. So what is counted is not force but **reversals** — the number of times the
6
+ * movement changed its mind inside a short window. That is what tells a shake apart from setting
7
+ * the phone down hard, from a pocket, from a car going over a kerb.
8
+ *
9
+ * Direction is deliberately not read. A sideways shake does carry a first impulse one way or the
10
+ * other, but which way that is depends on how the device is being held, and a control that works
11
+ * most of the time is worse than one that works the same way every time. So a shake means one
12
+ * thing, and two shakes in a row mean the other — the same bargain a double click makes.
13
+ *
14
+ * One thing follows from that and is worth saying rather than hiding: a shake that simply goes
15
+ * on long enough crosses the rest and is heard as a second one. Someone still shaking after a
16
+ * second and a half meant more than "the next one", so reading it as the other gesture is the
17
+ * least surprising of the available wrong answers.
18
+ */
19
+ /** One reading of the accelerometer, in m/s², gravity included or not — only the changes are read. */
20
+ export interface ShakeSample {
21
+ x: number;
22
+ y: number;
23
+ z: number;
24
+ /** When it was taken, in milliseconds. */
25
+ at: number;
26
+ }
27
+ export type ShakeGesture = 'single' | 'double';
28
+ export interface ShakeOptions {
29
+ /** How hard a movement has to be before it counts as one, in m/s² of change. */
30
+ force?: number;
31
+ /** How many changes of direction make a shake. */
32
+ reversals?: number;
33
+ /** How long those changes have to happen inside, in milliseconds. */
34
+ window?: number;
35
+ /** How long to ignore the accelerometer after a shake, so one shake is not read as three. */
36
+ rest?: number;
37
+ /**
38
+ * How long a second shake has to arrive within to mean "the other way", counted from the first.
39
+ * It has to leave room for the rest above, or a second shake would be swallowed before it could
40
+ * be heard — so the two are set together, not one at a time.
41
+ */
42
+ pairWindow?: number;
43
+ }
44
+ /**
45
+ * Reads samples and says when a shake happened.
46
+ *
47
+ * A single shake is reported only once it is clear no second one is coming, so that a double
48
+ * shake never arrives as a single one first and is then contradicted.
49
+ */
50
+ export declare function createShakeDetector(options?: ShakeOptions): {
51
+ read: (sample: ShakeSample) => ShakeGesture | null;
52
+ settle: (now: number) => ShakeGesture | null;
53
+ pendingFor: (now: number) => number;
54
+ reset: () => void;
55
+ };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Media kept behind a lock.
3
+ *
4
+ * What is locked is not merely refused: it is **absent**. It is in no shelf, no search, no
5
+ * history, no queue, until the vault is opened. Anything less tells whoever is holding the
6
+ * device that there is something to look for, which is the thing a lock is meant to avoid.
7
+ *
8
+ * The code is never kept. What is kept is a salt and the result of stretching the code through
9
+ * PBKDF2 with it, so the stored record cannot be read backwards, and the same code typed twice
10
+ * on two devices does not produce the same record.
11
+ */
12
+ /** What is written down about the code. The code itself never is. */
13
+ export interface VaultPasscode {
14
+ /** Random, per vault, so two vaults with the same code do not look alike. */
15
+ salt: string;
16
+ /** The stretched code, base64. */
17
+ hash: string;
18
+ /** How many rounds produced it, so a record made today still opens after the cost is raised. */
19
+ rounds: number;
20
+ }
21
+ /** The parts of Web Crypto this needs, named so a test can stand in for them. */
22
+ export interface VaultCrypto {
23
+ getRandomValues(array: Uint8Array): Uint8Array;
24
+ subtle: Pick<SubtleCrypto, 'importKey' | 'deriveBits'>;
25
+ }
26
+ export declare const VAULT_ROUNDS = 310000;
27
+ /**
28
+ * Stretches a code into something that can be written down.
29
+ *
30
+ * The rounds are the cost of one guess. They are stored with the record rather than assumed, so
31
+ * raising them later does not lock anyone out of a vault they already have.
32
+ */
33
+ export declare function hashPasscode(code: string, crypto: VaultCrypto, options?: {
34
+ salt?: string;
35
+ rounds?: number;
36
+ }): Promise<VaultPasscode>;
37
+ /**
38
+ * Whether a code opens a record. Compared in constant time, so the time an answer takes says
39
+ * nothing about how much of the code was right.
40
+ */
41
+ export declare function verifyPasscode(code: string, record: VaultPasscode | null, crypto: VaultCrypto): Promise<boolean>;
42
+ /** A code short enough to guess is not a code. Four is the floor every phone uses. */
43
+ export declare function isUsablePasscode(code: string): boolean;
44
+ /**
45
+ * The ids that must not be shown.
46
+ *
47
+ * Nothing is hidden while the vault is open, and nothing is hidden when there is no code — a
48
+ * vault nobody can open is a way of losing media, not of protecting it.
49
+ */
50
+ export declare function hiddenIds(locked: Iterable<string>, state: {
51
+ open: boolean;
52
+ hasPasscode: boolean;
53
+ }): Set<string>;
54
+ /** Keeps only what may be seen, in the order it was given. */
55
+ export declare function withoutHidden<T>(items: readonly T[], idOf: (item: T) => string, hidden: ReadonlySet<string>): T[];
@@ -0,0 +1,35 @@
1
+ import type { PlayerConfig } from '../types';
2
+ export interface CapabilityReport {
3
+ timestamp: number;
4
+ userAgent?: string;
5
+ source?: {
6
+ type?: string;
7
+ live?: boolean;
8
+ drm?: boolean;
9
+ url?: string;
10
+ contentId?: string;
11
+ };
12
+ platform: {
13
+ isSecureContext: boolean;
14
+ };
15
+ features: {
16
+ mse: boolean;
17
+ eme: boolean;
18
+ mediaCapabilities: boolean;
19
+ };
20
+ canPlay: Record<string, boolean>;
21
+ /**
22
+ * Optional, best-effort decoding probes via the MediaCapabilities API.
23
+ *
24
+ * Keys are stable labels (e.g. "h264_1080p").
25
+ */
26
+ mediaDecoding?: Record<string, {
27
+ supported: boolean;
28
+ smooth?: boolean;
29
+ powerEfficient?: boolean;
30
+ }>;
31
+ notes: string[];
32
+ }
33
+ /** Best-effort decoding probes used for diagnostics and ABR tuning hints. */
34
+ export declare function createMediaDecodingReport(): Promise<CapabilityReport['mediaDecoding']>;
35
+ export declare function createCapabilityReport(videoEl?: HTMLVideoElement, cfg?: PlayerConfig, mediaDecoding?: CapabilityReport['mediaDecoding']): CapabilityReport;
@@ -0,0 +1,19 @@
1
+ import type { PlayerConfig } from '../types';
2
+ import type { PlaybackEngine } from './playback-engine';
3
+ import type { PlaybackCapabilities } from './playback-capabilities';
4
+ export interface EngineFactory {
5
+ /** Unique id (ex: 'native', 'shaka') */
6
+ id: string;
7
+ /** Higher priority wins when multiple support the same source. Default 0. */
8
+ priority?: number;
9
+ /** Whether this engine supports this config/source. */
10
+ supports(config: PlayerConfig): boolean;
11
+ /**
12
+ * Optional, capability-aware selector.
13
+ * If present, it is preferred over supports().
14
+ */
15
+ supportsWithCaps?: (config: PlayerConfig, caps: PlaybackCapabilities) => boolean;
16
+ /** Create a new engine instance. */
17
+ create(): PlaybackEngine;
18
+ }
19
+ export declare function selectEngine(config: PlayerConfig, factories: EngineFactory[], caps?: PlaybackCapabilities): EngineFactory | null;
@@ -0,0 +1,27 @@
1
+ import type { EngineProfileId, PlayerSource } from '../types';
2
+ /**
3
+ * High-level playback profiles.
4
+ *
5
+ * Goal: provide good defaults with *minimal configuration*.
6
+ * Users can still override per-source hints via `source.abr`.
7
+ */
8
+ export interface EngineProfileHints {
9
+ /** Defaults applied only when the user did not specify `source.abr.*` */
10
+ abr?: {
11
+ maxHeight?: number;
12
+ maxBandwidth?: number;
13
+ };
14
+ /** Shaka-specific streaming knobs (best-effort, ignored by non-shaka engines). */
15
+ shakaStreaming?: {
16
+ lowLatencyMode?: boolean;
17
+ bufferingGoalSec?: number;
18
+ rebufferingGoalSec?: number;
19
+ };
20
+ }
21
+ export declare function getEngineProfileHints(profile?: EngineProfileId): EngineProfileHints;
22
+ /**
23
+ * Apply profile defaults to a `PlayerSource` without overriding user-provided hints.
24
+ *
25
+ * This function is intentionally conservative: it only fills missing fields.
26
+ */
27
+ export declare function applyEngineProfileToSource(source: PlayerSource, profile?: EngineProfileId): PlayerSource;
@@ -0,0 +1,23 @@
1
+ import { PlaybackEngine, EngineEvent } from './playback-engine';
2
+ import { MediaTrack, PlayerSource } from '../types';
3
+ export declare class NativeEngine implements PlaybackEngine {
4
+ readonly id = "native";
5
+ private video?;
6
+ private listeners;
7
+ private emit;
8
+ attach(videoEl: HTMLVideoElement): Promise<void>;
9
+ load(source: PlayerSource, opts?: {
10
+ startTimeSec?: number;
11
+ }): Promise<void>;
12
+ destroy(): Promise<void>;
13
+ play(): Promise<void>;
14
+ pause(): Promise<void>;
15
+ seekTo(timeSec: number): Promise<void>;
16
+ setPlaybackRate(rate: number): Promise<void>;
17
+ setVolume(volume: number): Promise<void>;
18
+ setTextTrack(_trackId: string | null): Promise<void>;
19
+ setAudioTrack(_trackId: string | null): Promise<void>;
20
+ setVideoTrack(_trackId: string | null): Promise<void>;
21
+ getTracks(): Promise<MediaTrack[]>;
22
+ onEvent(cb: (ev: EngineEvent) => void): () => void;
23
+ }
@@ -0,0 +1,2 @@
1
+ import type { EngineFactory } from './engine-factory';
2
+ export declare function createNativeEngineFactory(): EngineFactory;
@@ -0,0 +1,29 @@
1
+ export interface PlaybackCapabilities {
2
+ /** Browser has MediaSource (MSE). */
3
+ mse: boolean;
4
+ /** Browser has Encrypted Media Extensions (EME) API. */
5
+ eme: boolean;
6
+ /** True if navigator.mediaCapabilities is available. */
7
+ mediaCapabilities: boolean;
8
+ /** Whether basic HLS playback is possible via MSE/native. */
9
+ hls: boolean;
10
+ /** Whether basic DASH playback is possible via MSE. */
11
+ dash: boolean;
12
+ /** Progressive mp4/webm playback via <video src>. */
13
+ progressive: boolean;
14
+ /** Heuristic: support for at least one of common video codecs. */
15
+ codecs: {
16
+ mp4_h264: boolean;
17
+ mp4_hevc: boolean;
18
+ webm_vp9: boolean;
19
+ webm_av1: boolean;
20
+ };
21
+ /** Known DRM key systems availability (best-effort). */
22
+ drm: {
23
+ widevine: boolean;
24
+ playready: boolean;
25
+ fairplay: boolean;
26
+ };
27
+ }
28
+ export declare function createDefaultCapabilities(): PlaybackCapabilities;
29
+ export declare function detectPlaybackCapabilities(videoEl?: HTMLVideoElement): Promise<PlaybackCapabilities>;
@@ -0,0 +1,44 @@
1
+ import { PlayerSource, MediaTrack } from '../types';
2
+ export type EngineEvent = {
3
+ type: 'timeupdate';
4
+ currentTime: number;
5
+ duration: number;
6
+ } | {
7
+ type: 'bufferupdate';
8
+ bufferedAheadSec: number;
9
+ } | {
10
+ type: 'state';
11
+ state: 'loading' | 'buffering' | 'playing' | 'paused' | 'ended';
12
+ } | {
13
+ type: 'tracks';
14
+ tracks: MediaTrack[];
15
+ } | {
16
+ type: 'error';
17
+ error: {
18
+ code: string;
19
+ message: string;
20
+ fatal?: boolean;
21
+ details?: unknown;
22
+ };
23
+ };
24
+ export interface LoadOptions {
25
+ startTimeSec?: number;
26
+ /** Optional playlist index override for PlayerFacade */
27
+ playlistIndex?: number;
28
+ }
29
+ export interface PlaybackEngine {
30
+ readonly id: string;
31
+ attach(videoEl: HTMLVideoElement): Promise<void>;
32
+ load(source: PlayerSource, opts?: LoadOptions): Promise<void>;
33
+ destroy(): Promise<void>;
34
+ play(): Promise<void>;
35
+ pause(): Promise<void>;
36
+ seekTo(timeSec: number): Promise<void>;
37
+ setPlaybackRate(rate: number): Promise<void>;
38
+ setVolume(volume: number): Promise<void>;
39
+ setTextTrack(trackId: string | null): Promise<void>;
40
+ setAudioTrack(trackId: string | null): Promise<void>;
41
+ setVideoTrack(trackId: string | null): Promise<void>;
42
+ getTracks(): Promise<MediaTrack[]>;
43
+ onEvent(cb: (ev: EngineEvent) => void): () => void;
44
+ }
@@ -0,0 +1,77 @@
1
+ import type { PlayerSource, MediaTrack } from '../types';
2
+ import { type RemotePlaybackMedia, type RemotePlaybackSession } from '../domain/remote-playback';
3
+ import type { EngineFactory } from './engine-factory';
4
+ import type { EngineEvent, LoadOptions, PlaybackEngine } from './playback-engine';
5
+ export interface RemotePlaybackEngineOptions {
6
+ /** The device session media goes to; the engine only claims sources while one is set. */
7
+ session: () => RemotePlaybackSession | null;
8
+ /** What to send for a source: an address the device can reach, its type and display metadata. */
9
+ media: (source: PlayerSource, startSec: number) => RemotePlaybackMedia | Promise<RemotePlaybackMedia>;
10
+ /**
11
+ * The same media converted on the fly (`conversion`), for a device that refuses it as it is: a format or a codec
12
+ * it does not read. Only where the app can convert; the device gets it once it has refused the original.
13
+ */
14
+ convertedMedia?: (source: PlayerSource, startSec: number) => Promise<RemotePlaybackMedia>;
15
+ /** How often the device is asked where it is. */
16
+ pollMs?: number;
17
+ /** Above the native (0) and adaptive engines, so a session takes every source. */
18
+ priority?: number;
19
+ }
20
+ /**
21
+ * Plays through a remote device (DLNA renderer, Cast device) with the player's own controls. Like a media element,
22
+ * loading prepares the media and playing starts it: the device receives it on the first `play`, from the position
23
+ * reached until then. The device's position and state come back by polling. A device that refuses a media gets it
24
+ * converted when the app can convert it; a converted stream seeks by starting again from the new position.
25
+ */
26
+ export declare function createRemotePlaybackEngineFactory(options: RemotePlaybackEngineOptions): EngineFactory;
27
+ export declare class RemotePlaybackEngine implements PlaybackEngine {
28
+ private readonly options;
29
+ readonly id = "remote";
30
+ private readonly listeners;
31
+ private session;
32
+ private source;
33
+ /** What the device plays, as the app described it. */
34
+ private media;
35
+ private startSec;
36
+ private sent;
37
+ /** The device played the media to its end: it closed it, and only takes it again sent anew. */
38
+ private finished;
39
+ private durationSec;
40
+ private positionSec;
41
+ /** Where a converted stream starts in the media: the device counts from there. */
42
+ private offsetSec;
43
+ /** Furthest position the device reported since the media was sent: an end before any progress is a refusal. */
44
+ private furthestSec;
45
+ private conversionTried;
46
+ private lastState;
47
+ private timer;
48
+ private polling;
49
+ private failures;
50
+ private destroyed;
51
+ constructor(options: RemotePlaybackEngineOptions);
52
+ attach(videoEl: HTMLVideoElement): Promise<void>;
53
+ load(source: PlayerSource, opts?: LoadOptions): Promise<void>;
54
+ play(): Promise<void>;
55
+ pause(): Promise<void>;
56
+ seekTo(timeSec: number): Promise<void>;
57
+ setVolume(volume: number): Promise<void>;
58
+ setPlaybackRate(_rate: number): Promise<void>;
59
+ setTextTrack(_trackId: string | null): Promise<void>;
60
+ setAudioTrack(_trackId: string | null): Promise<void>;
61
+ setVideoTrack(_trackId: string | null): Promise<void>;
62
+ getTracks(): Promise<MediaTrack[]>;
63
+ onEvent(cb: (event: EngineEvent) => void): () => void;
64
+ /** Stops following the device; the session stays open for the next media. */
65
+ destroy(): Promise<void>;
66
+ /** Reads the device once; exposed for hosts and tests that do not want to wait for the timer. */
67
+ poll(): Promise<void>;
68
+ private restartAt;
69
+ /** Sends a media to the device from a position of it; a converted stream starts there and counts from 0. */
70
+ private send;
71
+ private convertible;
72
+ /** The device gave up on the media as it is: it gets it converted, from where it was. */
73
+ private convertAfterRefusal;
74
+ private startPolling;
75
+ private requireSession;
76
+ private emit;
77
+ }
@@ -0,0 +1,15 @@
1
+ import type { PlayerConfig } from '../types';
2
+ export interface PlaybackEngine {
3
+ attach(videoEl: HTMLVideoElement): void;
4
+ load(cfg: PlayerConfig): Promise<void>;
5
+ play(): Promise<void>;
6
+ pause(): void;
7
+ destroy(): Promise<void>;
8
+ }
9
+ export interface EngineFactory {
10
+ id: string;
11
+ canHandle(cfg: PlayerConfig): boolean;
12
+ create(): PlaybackEngine;
13
+ }
14
+ export declare function createNativeEngineFactory(): EngineFactory;
15
+ export declare function defaultEngineFactories(): EngineFactory[];
@@ -0,0 +1,15 @@
1
+ import type { PlayerEvent } from '../types';
2
+ export type Unsubscribe = () => void;
3
+ export interface PlayerEventBus {
4
+ emit(event: PlayerEvent): void;
5
+ on<T extends PlayerEvent['type']>(type: T, handler: (e: Extract<PlayerEvent, {
6
+ type: T;
7
+ }>) => void): Unsubscribe;
8
+ }
9
+ export declare class SimpleEventBus implements PlayerEventBus {
10
+ private handlers;
11
+ emit(event: PlayerEvent): void;
12
+ on<T extends PlayerEvent['type']>(type: T, handler: (e: Extract<PlayerEvent, {
13
+ type: T;
14
+ }>) => void): Unsubscribe;
15
+ }
@@ -0,0 +1,125 @@
1
+ import { Observable } from 'rxjs';
2
+ import { AspectRatioMode, MediaTrack, PlayerConfig, PlayerError, PlayerErrorCode, PlayerState, type DiagnosticsSnapshot } from '../types';
3
+ import { LoadOptions } from '../engine/playback-engine';
4
+ import type { EngineFactory } from '../engine/engine-factory';
5
+ import { type PlaybackCapabilities } from '../engine/playback-capabilities';
6
+ import { PlayerPlugin } from '../plugins/plugin';
7
+ import type { PlayerPorts } from '../ports/ports';
8
+ import { VideoMetadata } from '../plugins/metadata/metadata.types';
9
+ export interface PlayerSnapshot {
10
+ currentTime: number;
11
+ duration: number;
12
+ state: PlayerState;
13
+ bufferedAheadSec: number;
14
+ }
15
+ /**
16
+ * Public diagnostics payload.
17
+ *
18
+ * NOTE: This is intentionally an alias of `DiagnosticsSnapshot` to keep one
19
+ * canonical shape exported by `@ngxsp/core`.
20
+ */
21
+ export type PlayerDiagnostics = DiagnosticsSnapshot;
22
+ export declare class PlayerFacade {
23
+ private ports;
24
+ private engineFactories;
25
+ private engineId;
26
+ private lastNonFatal;
27
+ private mediaDecodingSub;
28
+ private video?;
29
+ private engine?;
30
+ private plugins;
31
+ private ctx?;
32
+ private stateSub;
33
+ private timeSub;
34
+ private bufferSub;
35
+ private tracksSub;
36
+ private errorSub;
37
+ private metadataSub;
38
+ private capsSub;
39
+ readonly capabilities$: Observable<PlaybackCapabilities | null>;
40
+ readonly state$: Observable<PlayerState>;
41
+ readonly time$: Observable<{
42
+ currentTime: number;
43
+ duration: number;
44
+ }>;
45
+ readonly bufferAheadSec$: Observable<number>;
46
+ readonly tracks$: Observable<MediaTrack[]>;
47
+ readonly error$: Observable<PlayerError>;
48
+ readonly metadata$: Observable<VideoMetadata | null>;
49
+ private seriesIndexSub;
50
+ readonly seriesIndex$: Observable<number | null>;
51
+ private playlistIndexSub;
52
+ readonly playlistIndex$: Observable<number | null>;
53
+ private playlist;
54
+ private playlistKey;
55
+ /** Subtitles loaded from files, shown by the host from `captionCues$` rather than by the browser. */
56
+ private externalTexts;
57
+ private externalTextCount;
58
+ /** The text track picked here; undefined while the engine's own choice stands. */
59
+ private textSelection;
60
+ private engineTracks;
61
+ private offCueChange?;
62
+ private captionCuesSub;
63
+ /** The cues of the loaded subtitles to show now: the host draws them over the video. */
64
+ readonly captionCues$: Observable<TextTrackCue[]>;
65
+ constructor(ports?: PlayerPorts);
66
+ attach(videoEl: HTMLVideoElement, plugins: PlayerPlugin[] | undefined, config: PlayerConfig, ports?: Partial<PlayerPorts>, engines?: EngineFactory[]): void;
67
+ load(config: PlayerConfig, opts?: LoadOptions): Promise<void>;
68
+ /**
69
+ * Replaces the engines the next load chooses from (a remote device session starting or ending). The native engine is
70
+ * always kept as fallback so progressive and local playback never breaks; call `load` or `reload` to switch now.
71
+ */
72
+ setEngines(engines?: EngineFactory[]): void;
73
+ reload(opts?: LoadOptions): Promise<void>;
74
+ next(): Promise<void>;
75
+ previous(): Promise<void>;
76
+ destroy(): Promise<void>;
77
+ /** Emit a non-fatal error (does not transition to fatal error state). */
78
+ emitNonFatal(err: unknown, code?: PlayerErrorCode | string): void;
79
+ /** Emit a fatal error (transitions to error state). */
80
+ private emitFatal;
81
+ private tryAutoNext;
82
+ private installed;
83
+ private qoe;
84
+ private installVideoEventListeners;
85
+ private emitTelemetry;
86
+ private toPlayerError;
87
+ play(): Promise<void>;
88
+ pause(): Promise<void>;
89
+ /**
90
+ * Seeks the attached engine. Resolves to false when no engine can take the request yet (a load is replacing it), so
91
+ * callers keep the position and apply it once the media is ready instead of assuming it happened.
92
+ */
93
+ seekTo(timeSec: number): Promise<boolean>;
94
+ setRate(rate: number): Promise<void>;
95
+ setVolume(volume: number): Promise<void>;
96
+ /**
97
+ * Shows a text track: one of the engine's, one loaded from a file (`addExternalTextTrack`), or none (null).
98
+ * "external" still names the last file loaded.
99
+ */
100
+ setTextTrack(trackId: string | null): Promise<void>;
101
+ /** Adds subtitles read from a file (WebVTT) to the media playing, and shows them; resolves to the new track's id. */
102
+ addExternalTextTrack(text: {
103
+ label: string;
104
+ language?: string;
105
+ vtt: string;
106
+ }): Promise<string>;
107
+ setAudioTrack(trackId: string | null): Promise<void>;
108
+ setVideoTrack(trackId: string | null): Promise<void>;
109
+ setAspectRatio(_mode: AspectRatioMode): void;
110
+ snapshot(): PlayerSnapshot;
111
+ /**
112
+ * Diagnostics helper for UI / support logs.
113
+ * Safe to call anytime after attach().
114
+ */
115
+ diagnostics(): PlayerDiagnostics;
116
+ setExternalVttTrack(lang: string, vtt: string): Promise<void>;
117
+ setMetadata(meta: VideoMetadata): void;
118
+ /** Shows `shown` (its cues go to `captionCues$`, the browser draws none) and turns the other files' subtitles off. */
119
+ private showExternalText;
120
+ private clearExternalTextTracks;
121
+ /** The engine's tracks and the loaded subtitles, the text track picked here marked active. */
122
+ private emitTracks;
123
+ private handleEngineEvent;
124
+ private tryRestoreStartTime;
125
+ }