chore: small bug fixes

This commit is contained in:
DanCodes committed 2024-01-10 11:01:55 +00:00
1 parent 049e6bb833
commit c5c10bd8cb
9 files changed
+167 -72

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ import AudioPlayer from "./components/playback/audioPlayer/index.jsx";
import { useAudioPlayback } from "./utils/store/audioPlayback.js";
import { useBackdropStore } from "./utils/store/backdrop.js";
import { useCentralStore } from "./utils/store/central.js";
import { usePlaybackDataLoadStore } from "./utils/store/playback.js";
import { usePlaybackDataLoadStore } from "./utils/store/playback";
// 3rd Party
import { CircularProgress } from "@mui/material";
+5
View File
@@ -58,6 +58,11 @@ const authenticateUser = async (
};
const init = async () => {
if (window.location.pathname !== "/") {
window.location.href = "/";
return;
}
const defaultServerOnDisk = await getDefaultServer();
if (defaultServerOnDisk) {
+2 -2
View File
@@ -153,7 +153,7 @@ const EpisodeTitlePage = () => {
setAudioTracks(audios);
setSubtitleTracks(subs);
}
});
}, [item.isSuccess, item.data?.MediaStreams]);
const [directors, setDirectors] = useState([]);
const [writers, setWriters] = useState([]);
@@ -180,7 +180,7 @@ const EpisodeTitlePage = () => {
const actorTp = item.data.People.filter((itm) => itm.Type === "Actor");
setActors(actorTp);
}
});
}, [item.isSuccess]);
const qualityLabel = () => {
if (
+1
View File
@@ -258,6 +258,7 @@ const PersonTitlePage = () => {
</Box>
);
}
if (item.isSuccess) {
return (
<motion.div
+12 -8
View File
@@ -19,7 +19,7 @@ import { MdiPlay } from "../../components/icons/mdiPlay";
import { usePlaybackStore } from "../../utils/store/playback";
import { useCallback, useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import { Navigate, useNavigate } from "react-router-dom";
import { secToTicks, ticksToSec } from "../../utils/date/time";
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
@@ -170,7 +170,7 @@ export const VideoPlayer = () => {
PlaySessionId: mediaInfo.data?.PlaySessionId,
},
});
console.log(startPosition);
playerRef.current.seekTo(timeToStart, "seconds");
setIsReady(true);
}
@@ -284,8 +284,6 @@ export const VideoPlayer = () => {
setItemId(episodes.data.Items[currentEpisodeIndex + 1].Id);
setDurationStore(episodes.data.Items[currentEpisodeIndex + 1].RunTimeTicks);
// navigate("player");
};
const handlePlayPrevEpisode = () => {
// Reset video player state
@@ -359,8 +357,6 @@ export const VideoPlayer = () => {
setItemId(episodes.data.Items[currentEpisodeIndex - 1].Id);
setDurationStore(episodes.data.Items[currentEpisodeIndex - 1].RunTimeTicks);
// navigate("player");
};
const [appFullscreen, setAppFullScreen] = useState(false);
@@ -436,7 +432,7 @@ export const VideoPlayer = () => {
return () => {
clearTimeout(timeout);
};
});
}, []);
const handleExit = async () => {
// Remove app from fullscreen
@@ -452,6 +448,7 @@ export const VideoPlayer = () => {
PositionTicks: currentTime,
},
});
navigate(-1);
// Reset playback store
@@ -469,7 +466,6 @@ export const VideoPlayer = () => {
};
const handleOnEnd = () => {
console.log("Playback ended");
if (seriesId) {
if (episodes.isSuccess && episodes.data.TotalRecordCount > 0) {
handlePlayNextEpisode();
@@ -510,6 +506,14 @@ export const VideoPlayer = () => {
}
};
if (!itemId) {
return (
<>
<Navigate to="/library/index" />;
</>
);
}
return (
<div
className="video-player-container"
+24
View File
@@ -0,0 +1,24 @@
function getVideoDebugInfo(videoElement: HTMLVideoElement) {
const quality = videoElement.getVideoPlaybackQuality();
const debugInfo = {
droppedFrames: quality.droppedVideoFrames,
totalFrames: quality.totalVideoFrames,
resolution: {
width: videoElement.videoWidth,
height: videoElement.videoHeight,
},
container:
videoElement.currentSrc.split(".").pop()?.split("?").pop() || "unknown",
duration: videoElement.duration,
currentTime: videoElement.currentTime,
playbackRate: videoElement.playbackRate,
volume: videoElement.volume,
currentQuality: {
width: videoElement.videoWidth,
height: videoElement.videoHeight,
},
};
return debugInfo;
}
-61
View File
@@ -1,61 +0,0 @@
import { create } from "zustand";
export const usePlaybackStore = create((set) => ({
url: "",
startPosition: 0,
duration: 0,
itemId: "",
itemName: "",
subtitleTracks: [],
selectedSubtitleTrack: 0,
mediaSourceId: "",
audioStreamIndex: 0,
videoStreamIndex: 0,
subtitleStreamIndex: 0,
userId: "",
mediaContainer: "",
seriesId: "",
queue: [],
episodeIndex: 0,
/**
* @type {import("@jellyfin/sdk/lib/generated-client/models/base-item-dto").BaseItemDto}
*/
item: {},
setUrl: (aurl) => set((state) => ({ ...state, url: aurl })),
setPosition: (apos) => set((state) => ({ ...state, startPosition: apos })),
setDuration: (adur) => set((state) => ({ ...state, duration: adur })),
setItemId: (aid) => set((state) => ({ ...state, itemId: aid })),
setItemName: (anm) => set((state) => ({ ...state, itemName: anm })),
setUserId: (anm) => set((state) => ({ ...state, userId: anm })),
setSeriesId: (anm) => set((state) => ({ ...state, seriesId: anm })),
setMediaContainer: (anm) =>
set((state) => ({ ...state, mediaContainer: anm })),
setMediaSourceId: (anm) => set((state) => ({ ...state, mediaSourceId: anm })),
setAudioStreamIndex: (anm) =>
set((state) => ({ ...state, audioStreamIndex: anm })),
setVideoStreamIndex: (anm) =>
set((state) => ({ ...state, videoStreamIndex: anm })),
setSubtitleStreamIndex: (anm) =>
set((state) => ({ ...state, subtitleStreamIndex: anm })),
setSubtitleTracks: (asub) =>
set((state) => ({
...state,
subtitleTracks: asub,
})),
setSelectedSubtitleTrack: (asub) =>
set((state) => ({ ...state, selectedSubtitleTrack: asub })),
setQueue: (qitem) => set((state) => ({ ...state, queue: qitem })),
setEpisodeIndex: (aitem) =>
set((state) => ({ ...state, episodeIndex: aitem })),
}));
export const setItem = (item) =>
usePlaybackStore.setState((state) => ({ ...state, item: item }));
export const usePlaybackDataLoadStore = create((set) => ({
isPending: false,
setisPending: (loading) =>
set((state) => ({
...state,
isPending: loading,
})),
}));
+119
View File
@@ -0,0 +1,119 @@
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
import { create } from "zustand";
export interface PlaybackState {
url: string;
startPosition: number;
duration: number;
itemId: string;
itemName: string;
subtitleTracks: unknown[];
selectedSubtitleTrack: number;
mediaSourceId: string;
audioStreamIndex: number;
videoStreamIndex: number;
subtitleStreamIndex: number;
userId: string;
mediaContainer: string;
seriesId: string;
queue: unknown[];
episodeIndex: number;
item: BaseItemDto;
setUrl: (aurl: string) => void;
setPosition: (apos: number) => void;
setDuration: (adur: number) => void;
setItemId: (aid: string) => void;
setItemName: (anm: string) => void;
setUserId: (anm: string) => void;
setSeriesId: (anm: string) => void;
setMediaContainer: (anm: string) => void;
setMediaSourceId: (anm: string) => void;
setAudioStreamIndex: (anm: number) => void;
setVideoStreamIndex: (anm: number) => void;
setSubtitleStreamIndex: (anm: number) => void;
setSubtitleTracks: (asub: unknown[]) => void;
setSelectedSubtitleTrack: (asub: number) => void;
setQueue: (qitem: unknown[]) => void;
setEpisodeIndex: (aitem: number) => void;
}
export const usePlaybackStore = create<PlaybackState>((set) => ({
url: "",
startPosition: 0,
duration: 0,
itemId: "",
itemName: "",
subtitleTracks: [],
selectedSubtitleTrack: 0,
mediaSourceId: "",
audioStreamIndex: 0,
videoStreamIndex: 0,
subtitleStreamIndex: 0,
userId: "",
mediaContainer: "",
seriesId: "",
queue: [],
episodeIndex: 0,
item: {} as BaseItemDto,
setUrl: (aurl: string) =>
set((state: PlaybackState) => ({ ...state, url: aurl })),
setPosition: (apos: number) =>
set((state: PlaybackState) => ({ ...state, startPosition: apos })),
setDuration: (adur: number) =>
set((state: PlaybackState) => ({ ...state, duration: adur })),
setItemId: (aid: string) =>
set((state: PlaybackState) => ({ ...state, itemId: aid })),
setItemName: (anm: string) =>
set((state: PlaybackState) => ({ ...state, itemName: anm })),
setUserId: (anm: string) =>
set((state: PlaybackState) => ({ ...state, userId: anm })),
setSeriesId: (anm: string) =>
set((state: PlaybackState) => ({ ...state, seriesId: anm })),
setMediaContainer: (anm: string) =>
set((state: PlaybackState) => ({ ...state, mediaContainer: anm })),
setMediaSourceId: (anm: string) =>
set((state: PlaybackState) => ({ ...state, mediaSourceId: anm })),
setAudioStreamIndex: (anm: number) =>
set((state: PlaybackState) => ({ ...state, audioStreamIndex: anm })),
setVideoStreamIndex: (anm: number) =>
set((state: PlaybackState) => ({ ...state, videoStreamIndex: anm })),
setSubtitleStreamIndex: (anm: number) =>
set((state: PlaybackState) => ({ ...state, subtitleStreamIndex: anm })),
setSubtitleTracks: (asub: unknown[]) =>
set((state: PlaybackState) => ({
...state,
subtitleTracks: asub,
})),
setSelectedSubtitleTrack: (asub: number) =>
set((state: PlaybackState) => ({
...state,
selectedSubtitleTrack: asub,
})),
setQueue: (qitem: unknown[]) =>
set((state: PlaybackState) => ({ ...state, queue: qitem })),
setEpisodeIndex: (aitem: number) =>
set((state: PlaybackState) => ({ ...state, episodeIndex: aitem })),
}));
export const setItem = (item: BaseItemDto) =>
usePlaybackStore.setState((state: PlaybackState) => ({
...state,
item: item,
}));
interface PlaybackDataLoadState {
isPending: boolean;
setisPending: (loading: boolean) => void;
}
export const usePlaybackDataLoadStore = create<PlaybackDataLoadState>(
(set) => ({
isPending: false,
setisPending: (loading: boolean) =>
set((state: PlaybackDataLoadState) => ({
...state,
isPending: loading,
})),
}),
);