From c553c754333b3c10eb070161f15da9993107a278 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 29 May 2026 12:32:20 +0200 Subject: [PATCH] Fix source/tech seleciton on web --- src/player.web.tsx | 3 +++ src/provider.web.tsx | 4 ++-- src/view.web.tsx | 13 ++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/player.web.tsx b/src/player.web.tsx index 87029f3..a8ac046 100644 --- a/src/player.web.tsx +++ b/src/player.web.tsx @@ -6,6 +6,7 @@ import type { Rendition, Track, } from "./types/player"; +import type { Source } from "./types/source"; export class WebOmniPlayer implements OmniPlayer { _store: VideoPlayerStore; @@ -16,6 +17,8 @@ export class WebOmniPlayer implements OmniPlayer { this._store = store; } + source: Source | null = null; + get showNotification(): boolean { // TODO return false; diff --git a/src/provider.web.tsx b/src/provider.web.tsx index 16d0812..edd68f3 100644 --- a/src/provider.web.tsx +++ b/src/provider.web.tsx @@ -41,8 +41,8 @@ const PlayerInitializer = ({ const player = useLazyRef(() => new WebOmniPlayer(store)); useEffect(() => { - store.source = source.src[0]?.uri || null; - }, [store, source]); + player.source = source; + }, [source]); useEffect(() => { player.showNotification = showNotification; diff --git a/src/view.web.tsx b/src/view.web.tsx index add167c..cf0e123 100644 --- a/src/view.web.tsx +++ b/src/view.web.tsx @@ -1,6 +1,8 @@ +import { HlsVideo } from "@videojs/react/media/hls-video"; import { Video } from "@videojs/react/video"; import type { CSSProperties } from "react"; import { useRef } from "react"; +import type { WebOmniPlayer } from "./player.web"; import { usePlayer, VideoPlayer } from "./provider.web"; import type { OmniViewProps } from "./types/view"; @@ -8,16 +10,17 @@ export const OmniView = ({ style, autoplay, }: OmniViewProps & { style: CSSProperties }) => { - const player = usePlayer(); + const player = usePlayer() as WebOmniPlayer; const containerRef = useRef(null); - const src = player.source.src[0]?.uri; + const uri = player.source?.src[0]?.uri; + const Tech = uri?.endsWith("m3u8") ? HlsVideo : Video; return ( - {src && ( -