diff --git a/src/big-picture/src/components/pages/game/screenshot-carousel/index.tsx b/src/big-picture/src/components/pages/game/screenshot-carousel/index.tsx index 4b1f144f10..ae214bfef7 100644 --- a/src/big-picture/src/components/pages/game/screenshot-carousel/index.tsx +++ b/src/big-picture/src/components/pages/game/screenshot-carousel/index.tsx @@ -1,4 +1,4 @@ -import { CaretLeftIcon, CaretRightIcon } from "@phosphor-icons/react"; +import { CaretLeftIcon, CaretRightIcon, PlayIcon } from "@phosphor-icons/react"; import type { SteamMovie, SteamScreenshot } from "@types"; import useEmblaCarousel from "embla-carousel-react"; import type { FocusOverrideTarget } from "../../../../services"; @@ -11,6 +11,7 @@ import { useState, } from "react"; import { getItemFocusTarget } from "../../../../helpers"; +import { useUserPreferences } from "../../../../hooks"; import { BIG_PICTURE_SIDEBAR_ITEM_IDS } from "../../../../layout"; import { FocusItem, HorizontalFocusGroup } from "../../../common"; import { useNavigationIsFocused, useNavigationStore } from "../../../../stores"; @@ -22,6 +23,8 @@ import { } from "../navigation"; import { VideoPlayer } from "./video-player"; +const PLAY_ICON_SIZE = 28; + interface ScreenshotCarouselProps { screenshots: SteamScreenshot[]; videos: SteamMovie[]; @@ -44,9 +47,15 @@ interface ScreenshotCarouselSlideProps { item: MediaItem; index: number; isSelected: boolean; + autoplayEnabled: boolean; + preferencesLoaded: boolean; + started: boolean; + isPlaying: boolean; onFocused: (index: number) => void; - onSelectItem: (index: number) => void; + onSelectItem: (index: number, target: EventTarget | null) => void; setVideoRef: (index: number, element: HTMLVideoElement | null) => void; + onVideoPlay: (index: number) => void; + onVideoPause: (index: number) => void; leftNavigationTarget?: FocusOverrideTarget; downNavigationTarget?: FocusOverrideTarget; rightNavigationTarget?: FocusOverrideTarget; @@ -56,9 +65,15 @@ function ScreenshotCarouselSlide({ item, index, isSelected, + autoplayEnabled, + preferencesLoaded, + started, + isPlaying, onFocused, onSelectItem, setVideoRef, + onVideoPlay, + onVideoPause, leftNavigationTarget, downNavigationTarget, rightNavigationTarget, @@ -89,28 +104,41 @@ function ScreenshotCarouselSlide({ + )} + + ); } diff --git a/src/shared/use-hls-video.ts b/src/shared/use-hls-video.ts index 54fe2de990..873746e788 100644 --- a/src/shared/use-hls-video.ts +++ b/src/shared/use-hls-video.ts @@ -4,6 +4,7 @@ import Hls from "hls.js"; interface UseHlsVideoOptions { videoSrc: string | undefined; videoType: string | undefined; + load?: boolean; autoplay?: boolean; muted?: boolean; loop?: boolean; @@ -21,14 +22,21 @@ const defaultLogger: HlsVideoLogger = { export function useHlsVideo( videoRef: React.RefObject, - { videoSrc, videoType, autoplay, muted, loop }: UseHlsVideoOptions, + { + videoSrc, + videoType, + load = true, + autoplay, + muted, + loop, + }: UseHlsVideoOptions, log: HlsVideoLogger = defaultLogger ) { const hlsRef = useRef(null); useEffect(() => { const video = videoRef.current; - if (!video || !videoSrc) return; + if (!video || !videoSrc || !load) return; const isHls = videoType === "application/x-mpegURL"; @@ -94,7 +102,7 @@ export function useHlsVideo( log.warn("HLS playback is not supported in this browser"); return undefined; - }, [videoRef, videoSrc, videoType, autoplay, muted, loop, log]); + }, [videoRef, videoSrc, videoType, load, autoplay, muted, loop, log]); useEffect(() => { const video = videoRef.current;