mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 03:56:15 -08:00
* fix(playback): keep the saved Embedded MPV player when the mpv check is inconclusive On Linux native-view the support check runs `mpv --version` by bare name and waits for the login shell PATH first. Since #1784 that lookup is asynchronous with a 10 s budget; when it ran out, the check ran on the inherited PATH and answered a plain `supported: false`. The settings store took that as a verdict and persisted the default player over a saved Embedded MPV selection. The main process probed again once the shell answered, but nothing restored the setting. `EmbeddedMpvSupport` now carries `inconclusive`. The native service sets it on a missing mpv while its probe has only seen the inherited PATH; the IPC handler declares that state before probing and registers the re-probe before the check, so a throwing check cannot leave it stuck. Every other answer stays final. Consumers no longer settle on an inconclusive answer: the settings store keeps the saved player, and the command palette and the settings search probe again on their next use instead of caching it for the session. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(playback): keep asking for Embedded MPV support while the answer is inconclusive Keeping the saved player on an inconclusive answer left a mounted player stuck on it: the session controller asked for support once, in its constructor, and the session effect never starts while unsupported, so the player did not recover after the login shell answered. The settings page held its one answer the same way. `watchEmbeddedMpvSupport()` asks again every 3 s until the answer is final or the surface is destroyed. The player controller and the settings page facade load support through it, so playback starts by itself and the Embedded MPV option appears without reopening the page. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(settings): follow an inconclusive Embedded MPV answer to a final decision The settings store checked a saved Embedded MPV selection once. After an inconclusive answer it kept the selection and never looked again, so when mpv turned out to be really missing the player stayed on Embedded MPV instead of falling back to the default one. The store now follows the answer with `watchEmbeddedMpvSupport()` until it is final and only then decides. It acts on an answer only while Embedded MPV is still the saved player, so a player picked meanwhile, also while the first answer was pending, is never overwritten. The watch backs off from 3 s to 30 s between rechecks, so a login shell that never answers does not keep the app polling at the first rate, and it no longer schedules a recheck after its answer handler stopped it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(settings): keep the settings search following an inconclusive Embedded MPV answer The settings page asks the search service for Embedded MPV support once, when its search facade is created. After an inconclusive answer the service only probed again on its next call, so with the page left open the Embedded MPV rows stayed unsearchable after the login shell answered, while the player option on the same page already updated. The service now follows the answer with `watchEmbeddedMpvSupport()` until it is final, which updates the open page and the command palette alike. A call made while the answer is still inconclusive restarts the watch, so it asks at once as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(settings): follow Embedded MPV support for search only while the settings page is open The settings search service is provided in the root injector, so the watch it started on its first use had no owner: with a login shell that never answers it kept asking every 30 s until the app quit, long after the settings page or the command palette that needed the answer was closed. A failed recheck also ended the watch as if it were a final answer, hiding the Embedded MPV rows for the rest of the session. The service now separates the two uses. `ensureEmbeddedMpvSupportLoaded()` is a single request again, for the command palette. The settings page calls `followEmbeddedMpvSupport()` and ends it when the page is destroyed. Only a final answer is kept: after an inconclusive one or a failed request the next use asks again, for the palette's player commands too. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
177 lines
6.0 KiB
TypeScript
177 lines
6.0 KiB
TypeScript
import type { PlayerSubtitleStyle } from './subtitle-style.util';
|
|
import type { RecordingStartMetadata } from './recording-metadata.interface';
|
|
|
|
export type EmbeddedMpvSessionStatus =
|
|
'idle' | 'loading' | 'playing' | 'paused' | 'ended' | 'error' | 'closed';
|
|
|
|
export interface EmbeddedMpvBounds {
|
|
x: number;
|
|
y: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export interface EmbeddedMpvCapabilities {
|
|
subtitles: boolean;
|
|
playbackSpeed: boolean;
|
|
aspectOverride: boolean;
|
|
screenshot: boolean;
|
|
recording: boolean;
|
|
/** Loading an external subtitle file via `sub-add` (frame-copy engine). */
|
|
externalSubtitles?: boolean;
|
|
/** Adjusting `sub-delay` at runtime (frame-copy engine). */
|
|
subtitleDelay?: boolean;
|
|
/** Adjusting `sub-scale`/`sub-color` at runtime (frame-copy engine). */
|
|
subtitleStyle?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Subtitle presentation preferences forwarded to mpv: `sizePercent` maps to
|
|
* `sub-scale` (100 = 1.0); `color` maps to `sub-color`, null restores mpv's
|
|
* default. Alias of the canonical shared shape so the renderer controls and
|
|
* the IPC contract cannot drift structurally.
|
|
*/
|
|
export type EmbeddedMpvSubtitleStyle = PlayerSubtitleStyle;
|
|
|
|
export type EmbeddedMpvEngine = 'native' | 'frame-copy';
|
|
|
|
export interface EmbeddedMpvSupport {
|
|
supported: boolean;
|
|
platform: string;
|
|
reason?: string;
|
|
/**
|
|
* True when `supported: false` is not a verdict on this machine yet: the
|
|
* Linux native-view `mpv` executable was looked up before the login shell
|
|
* PATH arrived, and is looked up again once the shell answers. Never
|
|
* persist a decision made from such an answer; ask again later.
|
|
*/
|
|
inconclusive?: boolean;
|
|
capabilities?: EmbeddedMpvCapabilities;
|
|
/**
|
|
* Rendering engine the main process will use for new sessions.
|
|
* `native` = platform video surface (NSOpenGLView/HWND/X11 wid),
|
|
* `frame-copy` = helper process + shm ring + renderer canvas.
|
|
*/
|
|
engine?: EmbeddedMpvEngine;
|
|
/**
|
|
* True when this machine could run the frame-copy engine (macOS arm64
|
|
* or Linux x64, after its helper/runtime capability gate), regardless of
|
|
* whether it is active.
|
|
* Drives the Settings toggle; switching engines requires an app restart.
|
|
*/
|
|
frameCopyAvailable?: boolean;
|
|
/**
|
|
* Stable fail-closed capability reason when frameCopyAvailable is false.
|
|
* Intended for startup tracing and support diagnostics, not user copy.
|
|
*/
|
|
frameCopyUnavailableReason?: string;
|
|
}
|
|
|
|
/**
|
|
* Where the renderer's frame pump finds the current shm frame ring of a
|
|
* frame-copy session. A new generation is announced after every viewport
|
|
* resize; the pump re-attaches to the new segment.
|
|
*/
|
|
export interface EmbeddedMpvFrameSource {
|
|
shmName: string;
|
|
width: number;
|
|
height: number;
|
|
generation: number;
|
|
readerPath: string;
|
|
}
|
|
|
|
export interface EmbeddedMpvAudioTrack {
|
|
id: number;
|
|
title?: string;
|
|
language?: string;
|
|
selected: boolean;
|
|
defaultTrack?: boolean;
|
|
forced?: boolean;
|
|
}
|
|
|
|
export type EmbeddedMpvSubtitleTrack = EmbeddedMpvAudioTrack;
|
|
|
|
export interface EmbeddedMpvRecordingState {
|
|
active: boolean;
|
|
targetPath?: string;
|
|
startedAt?: string;
|
|
error?: string;
|
|
}
|
|
|
|
/**
|
|
* Live stream diagnostics mpv reports for the player's info popover. Every
|
|
* field is optional: a property mpv has not answered yet (or an engine that
|
|
* does not observe it) simply omits its row rather than reporting a zero.
|
|
*/
|
|
export interface EmbeddedMpvStreamStats {
|
|
/** mpv `estimated-vf-fps` — the measured, not the container, rate. */
|
|
fps?: number;
|
|
/** mpv `video-bitrate` / `audio-bitrate`, in bits per second. */
|
|
videoBitrateBps?: number;
|
|
audioBitrateBps?: number;
|
|
/** mpv `video-format` / `audio-codec-name`, e.g. `h264` / `aac`. */
|
|
videoCodec?: string;
|
|
audioCodec?: string;
|
|
/** mpv `audio-params/channels`, e.g. `stereo` or `5.1`. */
|
|
audioChannels?: string;
|
|
/** mpv `audio-params/samplerate`, in Hz. */
|
|
audioSampleRateHz?: number;
|
|
/** mpv `file-format`, e.g. `mpegts` or `hls`. */
|
|
container?: string;
|
|
/** mpv `demuxer-cache-duration`: media buffered ahead, in seconds. */
|
|
bufferedAheadSeconds?: number;
|
|
/** mpv `frame-drop-count` plus `decoder-frame-drop-count`. */
|
|
droppedFrames?: number;
|
|
}
|
|
|
|
export interface EmbeddedMpvRecordingStartOptions {
|
|
directory?: string;
|
|
title?: string;
|
|
/**
|
|
* Channel/EPG snapshot captured by the live host at recording start; the
|
|
* main-process recording tracker persists it. See
|
|
* recording-metadata.interface.ts for why capture must happen up front.
|
|
*/
|
|
metadata?: RecordingStartMetadata;
|
|
}
|
|
|
|
export interface EmbeddedMpvSession {
|
|
id: string;
|
|
title: string;
|
|
streamUrl: string;
|
|
status: EmbeddedMpvSessionStatus;
|
|
positionSeconds: number;
|
|
durationSeconds: number | null;
|
|
volume: number;
|
|
audioTracks: EmbeddedMpvAudioTrack[];
|
|
selectedAudioTrackId: number | null;
|
|
subtitleTracks: EmbeddedMpvSubtitleTrack[];
|
|
selectedSubtitleTrackId: number | null;
|
|
playbackSpeed: number;
|
|
aspectOverride: string;
|
|
/** Source video size (mpv dwidth/dheight); frame-copy engine only. */
|
|
videoWidth?: number;
|
|
videoHeight?: number;
|
|
/** Live diagnostics for the info popover; absent when mpv reports none. */
|
|
stats?: EmbeddedMpvStreamStats;
|
|
recording?: EmbeddedMpvRecordingState;
|
|
startedAt: string;
|
|
updatedAt: string;
|
|
error?: string;
|
|
/**
|
|
* Present while the main process is waiting to reload a dropped stream
|
|
* or has such a reload in flight; absent once playback is back or the
|
|
* attempts are exhausted. Display only — the renderer never schedules.
|
|
*/
|
|
reconnect?: EmbeddedMpvReconnectInfo;
|
|
}
|
|
|
|
/** Progress of the main-process automatic reconnect for one session. */
|
|
export interface EmbeddedMpvReconnectInfo {
|
|
/** 1-based number of the attempt that is scheduled or in flight. */
|
|
attempt: number;
|
|
maxAttempts: number;
|
|
/** ISO timestamp at which the scheduled attempt fires. */
|
|
nextAttemptAt: string;
|
|
}
|