feat(source): add a source getter

This commit is contained in:
2026-07-24 12:38:21 +02:00
parent a2d5ede547
commit ecc8f08ffa
11 changed files with 102 additions and 85 deletions
+3 -7
View File
@@ -61,7 +61,7 @@ export class WebOmniPlayer implements OmniPlayer {
}
castOptions: CastOptions | null = null;
_source: Source | null = null;
_source: Source | undefined = undefined;
private _showNotification = false;
// Selected ASS/PGS subtitle (drawn by the overlay); `null` when the active
@@ -70,15 +70,11 @@ export class WebOmniPlayer implements OmniPlayer {
private overlaySubtitle: Subtitle | null = null;
private overlayListeners = new Set<() => void>();
get source(): Source | null {
get source(): Source | undefined {
return this._source;
}
setSource(source?: Source): void {
this.source = source ?? null;
}
set source(source: Source | null) {
set source(source: Source | undefined) {
this._source = source;
// Drop the overlay subtitle if it is not part of the new source.
if (
+1 -1
View File
@@ -24,7 +24,7 @@ export const OmniProvider = ({
const player = useLazyRef(() => ProviderFactory.createPlayer(source));
useEffect(() => {
player.setSource(source);
player.source = source;
}, [source]);
useEffect(() => {
+1 -1
View File
@@ -56,7 +56,7 @@ const PlayerInitializer = ({
const seekedForSrc = useRef<string | undefined>(undefined);
useEffect(() => {
player.source = source ?? null;
player.source = source;
const uri = source?.src[0]?.uri;
if (uri !== seekedForSrc.current) {
seekedForSrc.current = uri;
+1 -1
View File
@@ -3,7 +3,7 @@ import type { Source } from "./source";
export interface OmniPlayer extends OmniPlayerState {
showNotification?: boolean;
setSource(source?: Source): void;
source?: Source;
play(): void;
pause(): void;