diff --git a/src/components/buttons/playButton.tsx b/src/components/buttons/playButton.tsx index f602028..8576e6e 100644 --- a/src/components/buttons/playButton.tsx +++ b/src/components/buttons/playButton.tsx @@ -248,12 +248,16 @@ const PlayButton = ({ (value) => value.Type === "Video", ); + const isDirectPlay = + !result.mediaSource.MediaSources?.[0].SupportsTranscoding || + !result.mediaSource.MediaSources?.[0].TranscodingUrl; + playItem({ metadata: { itemName: itemName ?? "", episodeTitle: episodeTitle, isEpisode: !!item.SeriesId, - itemDuration: item.RunTimeTicks ?? 0, + itemDuration: playItemValue?.RunTimeTicks ?? item.RunTimeTicks ?? 0, item: playItemValue ?? item, mediaSegments: result.mediaSegments, userDataLastPlayedPositionTicks: startPosition ?? 0, @@ -274,6 +278,12 @@ const PlayButton = ({ enable: subtitle?.enable ?? false, }, audio: audio, + bitrate: result.mediaSource.MediaSources?.[0].Bitrate, + videoCodec: videoTrack?.[0]?.Codec, + audioCodec: audio.allTracks?.find((t) => t.Index === audio.track) + ?.Codec, + isDirectPlay: isDirectPlay, + transcodingUrl: result.mediaSource.MediaSources?.[0].TranscodingUrl, }, playbackStream: playbackUrl, playsessionId: result.mediaSource.PlaySessionId, diff --git a/src/components/playback/videoPlayer/EndsAtDisplay.tsx b/src/components/playback/videoPlayer/EndsAtDisplay.tsx index 7fbd1a0..af8d56e 100644 --- a/src/components/playback/videoPlayer/EndsAtDisplay.tsx +++ b/src/components/playback/videoPlayer/EndsAtDisplay.tsx @@ -8,11 +8,12 @@ const EndsAtDisplay = () => { const { currentTime, itemDuration } = usePlaybackStore( useShallow((state) => ({ currentTime: state.playerState.currentTime, - itemDuration: state.metadata.itemDuration, + itemDuration: + state.metadata.itemDuration ?? state.metadata.item?.RunTimeTicks, })), ); - if (!itemDuration) return null; + if (!itemDuration) return --:--; const remaining = itemDuration - (currentTime ?? 0); diff --git a/src/components/playback/videoPlayer/ErrorDisplay.tsx b/src/components/playback/videoPlayer/ErrorDisplay.tsx new file mode 100644 index 0000000..d700a0a --- /dev/null +++ b/src/components/playback/videoPlayer/ErrorDisplay.tsx @@ -0,0 +1,53 @@ +import { Button, Typography } from "@mui/material"; +import React from "react"; + +interface ErrorDisplayProps { + error: any; + onRetry?: () => void; + onExit?: () => void; +} + +const ErrorDisplay = ({ error, onRetry, onExit }: ErrorDisplayProps) => { + if (!error) return null; + + return ( +
+ + Playback Error + + + {error.message || "An unknown error occurred during playback."} + +
+ {onRetry && ( + + )} + {onExit && ( + + )} +
+
+ ); +}; + +export default ErrorDisplay; diff --git a/src/components/playback/videoPlayer/ProgressDisplay.tsx b/src/components/playback/videoPlayer/ProgressDisplay.tsx index e9bf705..47b28b6 100644 --- a/src/components/playback/videoPlayer/ProgressDisplay.tsx +++ b/src/components/playback/videoPlayer/ProgressDisplay.tsx @@ -4,12 +4,13 @@ import { useShallow } from "zustand/shallow"; import ticksDisplay from "@/utils/methods/ticksDisplay"; import { usePlaybackStore } from "@/utils/store/playback"; -const ProgressDislay = () => { +const ProgressDisplay = () => { const { currentTime, itemDuration, isUserSeeking, seekValue } = usePlaybackStore( useShallow((state) => ({ currentTime: state.playerState.currentTime, - itemDuration: state.metadata.itemDuration, + itemDuration: + state.metadata.itemDuration ?? state.metadata.item?.RunTimeTicks, isUserSeeking: state.playerState.isUserSeeking, seekValue: state.playerState.seekValue, })), @@ -19,9 +20,9 @@ const ProgressDislay = () => { {ticksDisplay(isUserSeeking ? (seekValue ?? 0) : (currentTime ?? 0))} - {ticksDisplay(itemDuration)} + {ticksDisplay(itemDuration ?? 0)} ); }; -export default ProgressDislay; +export default ProgressDisplay; diff --git a/src/components/playback/videoPlayer/StatsForNerds.tsx b/src/components/playback/videoPlayer/StatsForNerds.tsx new file mode 100644 index 0000000..77ed9b4 --- /dev/null +++ b/src/components/playback/videoPlayer/StatsForNerds.tsx @@ -0,0 +1,165 @@ +import { IconButton, Paper, Typography } from "@mui/material"; +import React, { type RefObject, useEffect, useState } from "react"; +import { useShallow } from "zustand/shallow"; +import { usePlaybackStore } from "@/utils/store/playback"; + +interface StatsForNerdsProps { + playerRef: RefObject; +} + +const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => { + const { + showStatsForNerds, + toggleShowStatsForNerds, + itemId, + mediaSourceId, + playsessionId, + volume, + isBuffering, + playbackStream, + mediaSource, + } = usePlaybackStore( + useShallow((state) => ({ + showStatsForNerds: state.playerState.showStatsForNerds, + toggleShowStatsForNerds: state.toggleShowStatsForNerds, + itemId: state.metadata.item?.Id, + mediaSourceId: state.mediaSource.id, + playsessionId: state.playsessionId, + volume: state.playerState.volume, + isBuffering: state.playerState.isBuffering, + playbackStream: state.playbackStream, + mediaSource: state.mediaSource, + })), + ); + + const [videoStats, setVideoStats] = useState<{ + resolution: string; + droppedFrames: number; + totalFrames: number; + buffered: string; + }>({ + resolution: "-", + droppedFrames: 0, + totalFrames: 0, + buffered: "-", + }); + + useEffect(() => { + if (!showStatsForNerds) return; + + const interval = setInterval(() => { + if (playerRef.current) { + const internalPlayer = playerRef.current as HTMLVideoElement; + if (internalPlayer) { + const quality = internalPlayer.getVideoPlaybackQuality?.(); + + let bufferedEnd = 0; + if (internalPlayer.buffered.length > 0) { + // Find the buffered range that covers the current time + for (let i = 0; i < internalPlayer.buffered.length; i++) { + if ( + internalPlayer.buffered.start(i) <= + internalPlayer.currentTime && + internalPlayer.buffered.end(i) >= internalPlayer.currentTime + ) { + bufferedEnd = internalPlayer.buffered.end(i); + break; + } + } + } + + setVideoStats({ + resolution: + internalPlayer.videoWidth && internalPlayer.videoHeight + ? `${internalPlayer.videoWidth}x${internalPlayer.videoHeight}` + : "-", + droppedFrames: quality?.droppedVideoFrames ?? 0, + totalFrames: quality?.totalVideoFrames ?? 0, + buffered: `${(bufferedEnd - internalPlayer.currentTime).toFixed(2)}s`, + }); + } + } + }, 1000); + + return () => clearInterval(interval); + }, [showStatsForNerds, playerRef]); + + if (!showStatsForNerds) return null; + + return ( + +
+ + Stats for Nerds + + + + close + + +
+ +
+ Video ID: {itemId} + Media Source ID: {mediaSourceId} + Play Session ID: {playsessionId} + Playback Method:{" "} + {mediaSource.isDirectPlay ? "Direct Play" : "Transcoding"} + Container: {mediaSource.container} + Video Codec: {mediaSource.videoCodec} + Audio Codec: {mediaSource.audioCodec} + Bitrate:{" "} + + {mediaSource.bitrate + ? `${(mediaSource.bitrate / 1000000).toFixed(2)} Mbps` + : "-"} + + Stream URL:{" "} + {playbackStream} + Resolution: {videoStats.resolution} + Volume: {Math.round(volume * 100)}% + Buffer Health: {videoStats.buffered} + Dropped Frames:{" "} + + {videoStats.droppedFrames} / {videoStats.totalFrames} + + Is Buffering: {isBuffering ? "Yes" : "No"} +
+
+ ); +}; + +export default StatsForNerds; diff --git a/src/components/playback/videoPlayer/bubbleSlider/index.tsx b/src/components/playback/videoPlayer/bubbleSlider/index.tsx index 0425625..c33d5f5 100644 --- a/src/components/playback/videoPlayer/bubbleSlider/index.tsx +++ b/src/components/playback/videoPlayer/bubbleSlider/index.tsx @@ -1,7 +1,14 @@ import type { TrickplayInfo } from "@jellyfin/sdk/lib/generated-client"; import { Slider, Tooltip, Typography } from "@mui/material"; import type { Instance } from "@popperjs/core"; -import React, { type MouseEvent, useMemo, useRef, useState } from "react"; +import React, { + type MouseEvent, + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from "react"; import { useShallow } from "zustand/shallow"; import { ticksToMs } from "@/utils/date/time"; import { useApiInContext } from "@/utils/store/api"; @@ -69,24 +76,54 @@ const BubbleSlider = () => { }); const popperRef = useRef(null); const areaRef = useRef(null); + const rafRef = useRef(null); const [hoverProgress, setHoverProgress] = useState(0); - const handleSliderHover = (event: MouseEvent) => { - positionRef.current = { x: event.clientX, y: event.clientY }; - const rect = areaRef.current!.getBoundingClientRect(); - const width = rect.width; - const distX = event.clientX - rect.left; - const percentageCovered = distX / width; - setHoverProgress(percentageCovered * (itemDuration ?? 0)); - if (popperRef.current != null) { - popperRef.current.update(); - } - }; + useEffect(() => { + return () => { + if (rafRef.current) { + cancelAnimationFrame(rafRef.current); + } + }; + }, []); + + const handleSliderHover = useCallback( + (event: MouseEvent) => { + const clientX = event.clientX; + const clientY = event.clientY; + + if ( + positionRef.current.x === clientX && + positionRef.current.y === clientY + ) { + return; + } + + positionRef.current = { x: clientX, y: clientY }; + + if (rafRef.current) return; + + rafRef.current = requestAnimationFrame(() => { + if (areaRef.current) { + const rect = areaRef.current.getBoundingClientRect(); + const width = rect.width; + const distX = clientX - rect.left; + const percentageCovered = distX / width; + setHoverProgress(percentageCovered * (itemDuration ?? 0)); + if (popperRef.current != null) { + popperRef.current.update(); + } + } + rafRef.current = null; + }); + }, + [itemDuration], + ); const chapterMarks = useMemo(() => { const marks: { value: number }[] = []; - itemChapters?.map((val) => { + itemChapters?.forEach((val) => { marks.push({ value: val.StartPositionTicks ?? 0 }); }); return marks; @@ -95,14 +132,15 @@ const BubbleSlider = () => { const sliderDisplayFormat = (value: number) => { const currentChapter = itemChapters?.filter((chapter, index) => { if (index + 1 === itemChapters?.length) { - return chapter; + return true; } if ( (itemChapters?.[index + 1]?.StartPositionTicks ?? value) - value >= 0 && (chapter.StartPositionTicks ?? value) - value < 0 ) { - return chapter; + return true; } + return false; }); let trickplayResolution: TrickplayInfo | undefined; @@ -126,6 +164,8 @@ const BubbleSlider = () => { trickplayResolution = trickplayResolutions[bestWidth]; } } + let trickplayStyle: React.CSSProperties | undefined; + if ( trickplayResolution?.TileWidth && trickplayResolution.TileHeight && @@ -155,101 +195,105 @@ const BubbleSlider = () => { }; const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString(); - const imageAspectRatio = + const _imageAspectRatio = trickplayResolution.Width / trickplayResolution.Height; - if (currentChapter?.[0]?.Name) { - return ( -
-
- - {currentChapter?.[0]?.Name} - - - {ticksDisplay(value)} - -
- ); - } - return ( -
-
- - {ticksDisplay(value)} - -
- ); + trickplayStyle = { + background: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`, + backgroundPositionX: `${backgroundOffsetX}px`, + backgroundPositionY: `${backgroundOffsetY}px`, + width: `${trickplayResolution.Width}px`, + height: `${trickplayResolution.Height}px`, + borderBottom: "1px solid rgba(255,255,255,0.1)", + borderRadius: 0, + }; } - if (currentChapter?.[0]?.Name) { - return ( -
- - {currentChapter?.[0]?.Name} - - + const chapterName = currentChapter?.[0]?.Name; + + return ( +
+ {trickplayStyle && ( +
+ )} +
+ {chapterName && ( + + {chapterName} + + )} + {ticksDisplay(value)}
- ); - } - return ( -
- - {ticksDisplay(value)} -
); }; + const virtualAnchorEl = useMemo(() => { + return { + getBoundingClientRect: () => { + return new DOMRect( + positionRef.current.x, + areaRef.current?.getBoundingClientRect().y ?? 0, + 0, + 0, + ); + }, + }; + }, []); + return ( { - return new DOMRect( - positionRef.current.x, - areaRef.current!.getBoundingClientRect().y, - 0, - 0, - ); - }, - }, + anchorEl: virtualAnchorEl, // disablePortal: true, }, tooltip: { - // className: "glass", + className: "glass", style: { - width: "34em", + width: "auto", + maxWidth: "none", overflow: "hidden", - padding: "12px", - borderRadius: "20px", + padding: "0", + borderRadius: "12px", }, }, }} diff --git a/src/components/playback/videoPlayer/controls.scss b/src/components/playback/videoPlayer/controls.scss index 8b8091b..44daf43 100644 --- a/src/components/playback/videoPlayer/controls.scss +++ b/src/components/playback/videoPlayer/controls.scss @@ -16,16 +16,29 @@ flex-direction: column; align-self: stretch; justify-content: space-between; - padding: 1em 2em; - background: linear-gradient(to top, rgb(0 0 0 / 0.7) 5vh, transparent 26vh 90vh, rgb(0 0 0 / 0.7)); + padding: 2em 3em; + background: linear-gradient( + to bottom, + rgba(0, 0, 0, 0.8) 0%, + rgba(0, 0, 0, 0) 25%, + rgba(0, 0, 0, 0) 75%, + rgba(0, 0, 0, 0.9) 100% + ); &.hovering { cursor: default; } &-controls { + display: flex; + flex-direction: column; + gap: 1em; + &-timeline-text { display: flex; align-items: stretch; justify-content: space-between; + margin-top: 0.5em; + font-weight: 500; + opacity: 0.9; } &-progress { display: flex; @@ -45,7 +58,7 @@ } &-buttons { display: flex; - gap: 0.4em; + gap: 0.5em; align-items: center; } } diff --git a/src/components/playback/videoPlayer/controls.tsx b/src/components/playback/videoPlayer/controls.tsx index ed6b0a3..f4efbe7 100644 --- a/src/components/playback/videoPlayer/controls.tsx +++ b/src/components/playback/videoPlayer/controls.tsx @@ -1,7 +1,7 @@ import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api"; -import { IconButton, Typography } from "@mui/material"; +import { IconButton, Slider, Typography } from "@mui/material"; import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow"; -import { motion } from "motion/react"; +import { AnimatePresence, motion } from "motion/react"; import React, { type MouseEvent, useCallback, @@ -30,7 +30,7 @@ import VideoPlayerSettingsMenu from "./settingsMenu"; import "./controls.scss"; import { clearQueue } from "@/utils/store/queue"; -import ProgressDislay from "./ProgressDisplay"; +import ProgressDisplay from "./ProgressDisplay"; /** * Constant for the volume change interval when using the mouse wheel. @@ -65,6 +65,7 @@ const VideoPlayerControls = ({ // seekValue, isPlayerMuted, volume, + setVolume, toggleIsPlayerMuted, increaseVolumeByStep, decreaseVolumeByStep, @@ -86,6 +87,7 @@ const VideoPlayerControls = ({ seekValue: state.playerState.seekValue, isPlayerMuted: state.playerState.isPlayerMuted, volume: state.playerState.volume, + setVolume: state.setVolume, toggleIsPlayerMuted: state.toggleIsPlayerMuted, increaseVolumeByStep: state.increaseVolumeByStep, decreaseVolumeByStep: state.decreaseVolumeByStep, @@ -115,6 +117,7 @@ const VideoPlayerControls = ({ }, [increaseVolumeByStep, decreaseVolumeByStep]); const [clickTimeout, setClickTimeout] = useState(null); + const [showVolumeControl, setShowVolumeControl] = useState(false); const [settingsMenuRef, setSettingsMenuRef] = useState(null); @@ -228,7 +231,7 @@ const VideoPlayerControls = ({
- +
@@ -245,68 +248,41 @@ const VideoPlayerControls = ({
-
- {/* setShowVolumeControl(false)} - > - - {isPlayerMuted ? 0 : Math.round(playerVolume * 100)} - - { - if (api && Array.isArray(newValue)) { - dispatch({ - type: VideoPlayerActionKind.SET_PLAYER_VOLUME, - payload: newValue[0], - }); - } else { - dispatch({ - type: VideoPlayerActionKind.SET_PLAYER_VOLUME, - payload: newValue, - }); - } - if (newValue === 0) - dispatch({ - type: VideoPlayerActionKind.SET_PLAYER_MUTED, - payload: true, - }); - else - dispatch({ - type: VideoPlayerActionKind.SET_PLAYER_MUTED, - payload: true, - }); +
setShowVolumeControl(false)} + > + + {showVolumeControl && ( + - */} - {/* TODO: Volume menu */} + > + { + const val = Array.isArray(newValue) + ? newValue[0] + : newValue; + setVolume(val); + }} + sx={{ width: 100, color: "white" }} + /> + + )} + { - // setShowVolumeControl(true); - // }} + onMouseEnter={() => setShowVolumeControl(true)} > {isPlayerMuted diff --git a/src/components/playback/videoPlayer/settingsMenu.tsx b/src/components/playback/videoPlayer/settingsMenu.tsx index 172bd6d..304a1bc 100644 --- a/src/components/playback/videoPlayer/settingsMenu.tsx +++ b/src/components/playback/videoPlayer/settingsMenu.tsx @@ -1,4 +1,10 @@ -import { MenuItem, Popover, TextField } from "@mui/material"; +import { + MenuItem, + Popover, + Switch, + TextField, + Typography, +} from "@mui/material"; import { toNumber } from "lodash"; import React, { type ChangeEventHandler, @@ -29,10 +35,17 @@ const VideoPlayerSettingsMenu = ({ const api = useApiInContext((state) => state.api); - const { mediaSource, setIsBuffering } = usePlaybackStore( + const { + mediaSource, + setIsBuffering, + showStatsForNerds, + toggleShowStatsForNerds, + } = usePlaybackStore( useShallow((state) => ({ mediaSource: state.mediaSource, setIsBuffering: state.setIsBuffering, + showStatsForNerds: state.playerState.showStatsForNerds, + toggleShowStatsForNerds: state.toggleShowStatsForNerds, })), ); @@ -131,6 +144,10 @@ const VideoPlayerSettingsMenu = ({ ))} + + Stats for Nerds + + ); }; diff --git a/src/routes/_api/player/index.tsx b/src/routes/_api/player/index.tsx index aacbca8..683c790 100644 --- a/src/routes/_api/player/index.tsx +++ b/src/routes/_api/player/index.tsx @@ -23,7 +23,9 @@ import pgsWorkerUrl from "libpgs/dist/libpgs.worker.js?url"; import { useShallow } from "zustand/shallow"; import SkipSegmentButton from "@/components/playback/videoPlayer/buttons/SkipSegmentButton"; import VideoPlayerControls from "@/components/playback/videoPlayer/controls"; +import ErrorDisplay from "@/components/playback/videoPlayer/ErrorDisplay"; import LoadingIndicator from "@/components/playback/videoPlayer/LoadingIndicator"; +import StatsForNerds from "@/components/playback/videoPlayer/StatsForNerds"; import UpNextFlyout from "@/components/playback/videoPlayer/upNextFlyout"; import VolumeChangeOverlay from "@/components/playback/videoPlayer/VolumeChangeOverlay"; import getImageUrlsApi from "@/utils/methods/getImageUrlsApi"; @@ -150,6 +152,8 @@ export function VideoPlayer() { s.tracks, ]); + const [error, setError] = React.useState(null); + const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop)); useEffect(() => setBackdrop(""), []); @@ -217,12 +221,6 @@ export function VideoPlayer() { seekTo: (seconds: number) => { const internalPlayer = player.current; if (internalPlayer) { - const current = internalPlayer.currentTime; - - if (Math.abs(current - seconds) < 0.1) { - return; - } - internalPlayer.currentTime = seconds; console.log("Seeking to", seconds, "seconds"); } else { @@ -232,7 +230,7 @@ export function VideoPlayer() { getCurrentTime: () => { const internalPlayer = player.current; if (internalPlayer) { - return internalPlayer.currentTime; + return internalPlayer.currentTime ?? 0; } console.warn("ReactPlayer is not ready yet"); return 0; @@ -265,7 +263,8 @@ export function VideoPlayer() { const handleTimeUpdate = useCallback(async () => { if (!player.current) return; - const currentTime = player.current.currentTime; + const currentTime = player.current.currentTime ?? 0; + const ticks = secToTicks(currentTime); const now = Date.now(); @@ -318,6 +317,11 @@ export function VideoPlayer() { if (!api) { throw Error("API is not available, cannot report playback stopped."); } + let currentTime = 0; + if (player.current) { + currentTime = player.current.currentTime ?? 0; + } + // Report Jellyfin server: Playback has ended/stopped getPlaystateApi(api).reportPlaybackStopped({ playbackStopInfo: { @@ -325,7 +329,7 @@ export function VideoPlayer() { ItemId: itemId, MediaSourceId: mediaSource.id, PlaySessionId: playsessionId, - PositionTicks: secToTicks(player.current?.currentTime ?? 0), + PositionTicks: secToTicks(currentTime), }, }); usePlaybackStore.setState(usePlaybackStore.getInitialState()); @@ -335,12 +339,20 @@ export function VideoPlayer() { const handleKeyPress = useCallback((event: KeyboardEvent) => { if (player.current) { event.preventDefault(); + const currentTime = player.current.currentTime ?? 0; + + const seekTo = (time: number) => { + if (player.current) { + player.current.currentTime = time; + } + }; + switch (event.key) { case "ArrowRight": - player.current.currentTime += 10; + seekTo(currentTime + 10); break; case "ArrowLeft": - player.current.currentTime -= 10; + seekTo(currentTime - 10); break; case "F8": case " ": @@ -516,6 +528,11 @@ export function VideoPlayer() { setIsBuffering(false); }, [setIsBuffering]); + const handleError = useCallback((e: any) => { + console.error("Video playback error:", e); + setError(e); + }, []); + if (!playbackStream) { return (
@@ -540,6 +557,20 @@ export function VideoPlayer() { onMouseLeave={handleMouseLeave} > + { + setError(null); + if (player.current) { + // Try to reload the video + if (typeof player.current.load === "function") { + player.current.load(); + } + } + }} + /> + void; + /** + * Toggle the stats for nerds dialog + */ + toggleShowStatsForNerds: () => void; setPlayerState: (playerState: PlaybackStoreState["playerState"]) => void; // Playback information related actions @@ -288,6 +301,7 @@ export const usePlaybackStore = create< isUserSeeking: false, seekValue: 0, isLoading: true, + showStatsForNerds: false, }, userId: undefined!, // -- MediaSegment skip feature -- @@ -399,6 +413,11 @@ export const usePlaybackStore = create< id: string | undefined, subtitle: subtitlePlaybackInfo, audio: audioPlaybackInfo, + bitrate?: number, + videoCodec?: string, + audioCodec?: string, + isDirectPlay?: boolean, + transcodingUrl?: string, ) => set((state) => { state.mediaSource.videoTrack = videoTrack; @@ -407,6 +426,11 @@ export const usePlaybackStore = create< state.mediaSource.id = id; state.mediaSource.subtitle = subtitle; state.mediaSource.audio = audio; + state.mediaSource.bitrate = bitrate; + state.mediaSource.videoCodec = videoCodec; + state.mediaSource.audioCodec = audioCodec; + state.mediaSource.isDirectPlay = isDirectPlay; + state.mediaSource.transcodingUrl = transcodingUrl; }), setPlaybackStream: (playbackStream: string) => set((state) => { @@ -445,6 +469,11 @@ export const usePlaybackStore = create< set((state) => { state.playerState.isLoading = isLoading; }), + toggleShowStatsForNerds: () => + set((state) => { + state.playerState.showStatsForNerds = + !state.playerState.showStatsForNerds; + }), setPlayerState: (playerState) => set((state) => ({ ...state, @@ -783,6 +812,8 @@ export const playItemFromQueue = async ( (value) => value.Type === "Video", ); + const isDirectPlay = !source.SupportsTranscoding || !source.TranscodingUrl; + playItem({ metadata: { itemName, @@ -809,6 +840,11 @@ export const playItemFromQueue = async ( enable: subtitle?.enable ?? false, }, audio: audio, + bitrate: source.Bitrate, + videoCodec: videoTrack?.[0]?.Codec, + audioCodec: audio.allTracks?.find((t) => t.Index === audio.track)?.Codec, + isDirectPlay: isDirectPlay, + transcodingUrl: source.TranscodingUrl, }, playbackStream: playbackUrl, playsessionId: mediaSource.PlaySessionId,