fix: subtitles not being rendered #401
This commit is contained in:
16 files changed
+591
-652
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import useDebounce from "@/utils/hooks/useDebounce";
|
||||
import React, {
|
||||
type ReactNode,
|
||||
useCallback,
|
||||
@@ -11,12 +10,7 @@ import { useSpring } from "@react-spring/web";
|
||||
import { debounce } from "lodash";
|
||||
|
||||
import "./style.scss";
|
||||
import { Button, IconButton } from "@mui/material";
|
||||
|
||||
enum Direction {
|
||||
RIGHT = 0,
|
||||
LEFT = 1,
|
||||
}
|
||||
import { IconButton } from "@mui/material";
|
||||
|
||||
const Slider = ({
|
||||
content,
|
||||
@@ -148,13 +142,13 @@ const Slider = ({
|
||||
className="slider-button left"
|
||||
onClick={slideLeft}
|
||||
disabled={scrollPos.isStart}
|
||||
variant="contained"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_left</span>
|
||||
</IconButton>
|
||||
<div className="slider-track" ref={containerRef} onScroll={onScroll}>
|
||||
{content?.map((item, index) => (
|
||||
<div
|
||||
//biome-ignore lint/suspicious/noArrayIndexKey: item does not have a unique key
|
||||
key={index}
|
||||
className={
|
||||
currentSlide === index
|
||||
@@ -170,7 +164,6 @@ const Slider = ({
|
||||
className="slider-button right"
|
||||
onClick={slideRight}
|
||||
disabled={scrollPos.isEnd}
|
||||
variant="contained"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
</IconButton>
|
||||
|
||||
@@ -76,7 +76,7 @@ const QueueButton = () => {
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
{queueItems[currentItemIndex].Id && (
|
||||
{queueItems[currentItemIndex]?.Id && (
|
||||
<>
|
||||
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
||||
Currently Playing:
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
aspect-ratio: 1;
|
||||
position: relative;
|
||||
width: 4em;
|
||||
box-shadow: 0 0 10px rgb(0 0 0 / 0.2);
|
||||
transition: opacity $transition-time-default;
|
||||
&-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -39,8 +41,6 @@
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-fast;
|
||||
}
|
||||
box-shadow: 0 0 10px rgb(0 0 0 / 0.2);
|
||||
transition: opacity $transition-time-default;
|
||||
}
|
||||
&-info {
|
||||
justify-self: start;
|
||||
|
||||
@@ -10,21 +10,16 @@ import {
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Fab,
|
||||
FormControlLabel,
|
||||
IconButton,
|
||||
LinearProgress,
|
||||
Link,
|
||||
Skeleton,
|
||||
Switch,
|
||||
Tab,
|
||||
Tabs,
|
||||
TextField,
|
||||
Typography,
|
||||
styled,
|
||||
withStyles,
|
||||
} from "@mui/material";
|
||||
import { AnimatePresence, motion, transform } from "framer-motion";
|
||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import React, { useState, useMemo, useCallback } from "react";
|
||||
|
||||
import logo from "@/assets/logo.png";
|
||||
|
||||
@@ -41,14 +36,14 @@ import {
|
||||
setDefaultServer,
|
||||
setServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { allSettings, getSetting, setSetting } from "@/utils/storage/settings";
|
||||
import { allSettings } from "@/utils/storage/settings";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { red, yellow } from "@mui/material/colors";
|
||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
||||
import { red } from "@mui/material/colors";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { type Update, check } from "@tauri-apps/plugin-updater";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { useSnackbar } from "notistack";
|
||||
import SettingOption from "../settingOption";
|
||||
|
||||
@@ -82,10 +77,7 @@ const Settings = () => {
|
||||
const navigate = useNavigate();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [applicationVersion, serversOnDiskFn] = useCentralStore((state) => [
|
||||
state.clientVersion,
|
||||
state.allServersOnDisk,
|
||||
]);
|
||||
const [applicationVersion] = useCentralStore((state) => [state.clientVersion]);
|
||||
|
||||
const serversOnDisk = useQuery({
|
||||
queryKey: ["settings", "serversOnDisk"],
|
||||
@@ -524,14 +516,6 @@ const Settings = () => {
|
||||
{systemInfo.data?.Version}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">
|
||||
Operating System:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.OperatingSystemDisplayName}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">
|
||||
Server Architecture:
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
.settings{
|
||||
.settings {
|
||||
display: grid !important;
|
||||
grid-template-columns: 20% 1fr;
|
||||
height: 60vh;
|
||||
overflow: hidden !important;
|
||||
.MuiTabs-flexContainerVertical{
|
||||
.MuiTabs-flexContainerVertical {
|
||||
height: 100%;
|
||||
}
|
||||
&-container{
|
||||
&-container {
|
||||
margin: 14px 0 14px 14px;
|
||||
}
|
||||
&-tab{
|
||||
&-tab {
|
||||
display: grid !important;
|
||||
grid-template-columns: 2em 1fr;
|
||||
align-items: center;
|
||||
justify-items: start !important;
|
||||
gap:1em;
|
||||
& .material-symbols-rounded{
|
||||
gap: 1em;
|
||||
& .material-symbols-rounded {
|
||||
justify-self: center !important;
|
||||
}
|
||||
|
||||
}
|
||||
&-scroll{
|
||||
&-scroll {
|
||||
overflow-y: auto;
|
||||
scrollbar-gutter:stable ;
|
||||
scrollbar-gutter: stable;
|
||||
overscroll-behavior: contain;
|
||||
// Magic scrollbar
|
||||
&::-webkit-scrollbar {
|
||||
@@ -37,14 +36,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// About page
|
||||
&-grid{
|
||||
&-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap:1em;
|
||||
gap: 1em;
|
||||
}
|
||||
&-logo{
|
||||
&-logo {
|
||||
width: 100%;
|
||||
background: rgb(255 255 255 / 1);
|
||||
padding: 0em;
|
||||
@@ -53,7 +51,7 @@
|
||||
border-radius: $border-radius-default;
|
||||
object-fit: contain;
|
||||
}
|
||||
&-info{
|
||||
&-info {
|
||||
display: grid;
|
||||
grid-template-columns: 40% 1fr;
|
||||
gap: 1em;
|
||||
@@ -61,13 +59,13 @@
|
||||
align-items: center;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
||||
padding-bottom: 0.5em;
|
||||
&-container{
|
||||
&-container {
|
||||
background: rgb(0 0 0 / 0.3);
|
||||
padding: 1em;
|
||||
border-radius: $border-radius-default;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap:0.6em;
|
||||
gap: 0.6em;
|
||||
width: 100%;
|
||||
}
|
||||
&:last-child {
|
||||
@@ -78,9 +76,8 @@
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
//settings
|
||||
&-option{
|
||||
&-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -88,21 +85,12 @@
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
margin-bottom: 0.6em !important;
|
||||
&-info-caption{
|
||||
&-info-caption {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
//serverList
|
||||
&-server{
|
||||
&-container{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
align-items: center;
|
||||
padding-bottom: 4.6em;
|
||||
}
|
||||
|
||||
&-server {
|
||||
display: grid;
|
||||
grid-template-columns: 3.4em 1fr auto;
|
||||
justify-items: start;
|
||||
@@ -112,7 +100,13 @@
|
||||
padding: 1em;
|
||||
width: 100%;
|
||||
border-radius: $border-radius-default;
|
||||
|
||||
&-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
align-items: center;
|
||||
padding-bottom: 4.6em;
|
||||
}
|
||||
&-icon {
|
||||
font-size: 3.4em !important;
|
||||
font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 10, "opsz" 40;
|
||||
@@ -124,7 +118,7 @@
|
||||
&-version {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap:0.4em;
|
||||
gap: 0.4em;
|
||||
}
|
||||
}
|
||||
&-buttons {
|
||||
@@ -134,7 +128,6 @@
|
||||
// width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&-fab-container {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
@@ -144,7 +137,6 @@
|
||||
justify-content: center;
|
||||
gap: 0.8em;
|
||||
}
|
||||
|
||||
// Dialog
|
||||
&-add {
|
||||
display: flex;
|
||||
@@ -154,7 +146,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.Mui-selected .material-symbols-rounded{
|
||||
.Mui-selected .material-symbols-rounded {
|
||||
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
||||
}
|
||||
@@ -3,12 +3,12 @@ $border-radius: 20px;
|
||||
.item-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
&-container {
|
||||
gap: 1.2em;
|
||||
&-container {
|
||||
grid-template-columns: 1fr 25%;
|
||||
display: grid;
|
||||
gap: 3em;
|
||||
}
|
||||
gap: 1.2em;
|
||||
&-sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -19,21 +19,19 @@ import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
||||
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api";
|
||||
import { getGenresApi } from "@jellyfin/sdk/lib/utils/api/genres-api";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getMusicGenresApi } from "@jellyfin/sdk/lib/utils/api/music-genres-api";
|
||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
||||
|
||||
import GenreView from "@/components/layouts/library/genreView";
|
||||
import MusicTrack from "@/components/musicTrack";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import {
|
||||
type BaseItemDtoQueryResult,
|
||||
BaseItemKind,
|
||||
@@ -45,7 +43,13 @@ import {
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { FormControl, Menu, Stack, useScrollTrigger } from "@mui/material";
|
||||
import {
|
||||
FormControl,
|
||||
Menu,
|
||||
Select,
|
||||
Stack,
|
||||
useScrollTrigger,
|
||||
} from "@mui/material";
|
||||
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import "./library.scss";
|
||||
@@ -599,7 +603,7 @@ function LibraryView() {
|
||||
return result.data;
|
||||
},
|
||||
// enabled: false,
|
||||
enabled: user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
||||
enabled: !!user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
||||
networkMode: "always",
|
||||
// gcTime: 0,
|
||||
});
|
||||
@@ -686,6 +690,8 @@ function LibraryView() {
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||
|
||||
const backdropItems = useMemo(() => {
|
||||
if (items.isSuccess) {
|
||||
const temp = items.data.Items?.filter(
|
||||
@@ -724,6 +730,8 @@ function LibraryView() {
|
||||
}
|
||||
}, [backdropItems]);
|
||||
|
||||
const [test, setTest] = useState(1);
|
||||
|
||||
if (items.isError) {
|
||||
console.error(items.error);
|
||||
}
|
||||
@@ -833,6 +841,7 @@ function LibraryView() {
|
||||
size="small"
|
||||
onChange={(e) => {
|
||||
setSortBy(e.target.value as ItemSortBy);
|
||||
console.info(e);
|
||||
sessionStorage.setItem(
|
||||
`library-${currentLib.data?.Id}-config_sort`,
|
||||
JSON.stringify({
|
||||
@@ -879,6 +888,7 @@ function LibraryView() {
|
||||
</span>
|
||||
}
|
||||
size="large"
|
||||
//@ts-ignore
|
||||
color="white"
|
||||
onClick={handleFilterDropdown}
|
||||
>
|
||||
|
||||
@@ -84,6 +84,9 @@
|
||||
}
|
||||
}
|
||||
&-filter {
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
margin: 0 0.5em !important;
|
||||
&-container {
|
||||
margin-top: 0.75em;
|
||||
width: 22em;
|
||||
@@ -92,12 +95,7 @@
|
||||
border-radius: $border-radius-default;
|
||||
backdrop-filter: blur(10px);
|
||||
overflow-y: overlay;
|
||||
}
|
||||
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
margin: 0 0.5em !important;
|
||||
|
||||
}
|
||||
&-title {
|
||||
justify-self: start;
|
||||
}
|
||||
@@ -131,6 +129,14 @@
|
||||
}
|
||||
// Layout css for dynamic virtual rows
|
||||
&-virtual-item{
|
||||
width: 14%;
|
||||
flex-basis: 14%;
|
||||
height: fit-content;
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0.75em;
|
||||
&-row{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -138,14 +144,5 @@
|
||||
align-items: center;
|
||||
flex-basis: 14%;
|
||||
}
|
||||
width: 14%;
|
||||
flex-basis: 14%;
|
||||
height: fit-content;
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0.75em;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import React from "react";
|
||||
import React, { type ChangeEventHandler, useTransition } from "react";
|
||||
import { useLayoutEffect, useMemo } from "react";
|
||||
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import { Button, LinearProgress, TextField } from "@mui/material";
|
||||
import JASSUB from "jassub";
|
||||
@@ -48,14 +48,14 @@ import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import OutroCard from "@/components/outroCard";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useQueue, { clearQueue } from "@/utils/store/queue";
|
||||
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
||||
import { toNumber } from "lodash";
|
||||
import type { OnProgressProps } from "react-player/base";
|
||||
import type { TrackProps } from "react-player/file";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
import font from "./Noto-Sans-Indosphere.ttf?url";
|
||||
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
const time = Math.round(ticks / 10000);
|
||||
@@ -80,11 +80,50 @@ const ticksDisplay = (ticks: number) => {
|
||||
};
|
||||
const VOLUME_SCROLL_INTERVAL = 0.02;
|
||||
|
||||
/**
|
||||
* This function is used to add a subtitle track (.vtt and .srt) to the react player instance.
|
||||
*/
|
||||
function addSubtitleTrackToReactPlayer(
|
||||
videoElem: HTMLMediaElement,
|
||||
subtitleTracks,
|
||||
baseUrl: string,
|
||||
) {
|
||||
if (subtitleTracks.url && subtitleTracks.allTracks) {
|
||||
const reqSubTrack = subtitleTracks.allTracks.filter(
|
||||
(val) => val.Index === subtitleTracks.track,
|
||||
);
|
||||
const track = document.createElement("track");
|
||||
track.src = `${baseUrl}${subtitleTracks.url}`;
|
||||
track.kind = "subtitles";
|
||||
track.srclang = reqSubTrack[0].Language ?? "en";
|
||||
track.label = reqSubTrack[0].DisplayTitle ?? "Subtitle";
|
||||
track.default = true;
|
||||
|
||||
track.addEventListener("load", () => {
|
||||
console.log("Track loaded");
|
||||
const a = track.track;
|
||||
a.mode = "showing";
|
||||
});
|
||||
track.addEventListener("error", (e) => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
videoElem.appendChild(track);
|
||||
|
||||
for (const i of videoElem.textTracks) {
|
||||
if (i.label === reqSubTrack[0].DisplayTitle) {
|
||||
i.mode = "showing";
|
||||
} else {
|
||||
i.mode = "hidden";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const Route = createFileRoute("/_api/player/")({
|
||||
component: VideoPlayer,
|
||||
});
|
||||
|
||||
|
||||
function VideoPlayer() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const { history } = useRouter();
|
||||
@@ -137,6 +176,7 @@ function VideoPlayer() {
|
||||
const [volume, setVolume] = useState(1);
|
||||
const [muted, setMuted] = useState(false);
|
||||
|
||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||
useEffect(() => setBackdrop("", ""), []);
|
||||
|
||||
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout>(null!);
|
||||
@@ -255,7 +295,6 @@ function VideoPlayer() {
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// attach the event listener
|
||||
document.addEventListener("keydown", handleKeyPress);
|
||||
@@ -266,6 +305,7 @@ function VideoPlayer() {
|
||||
};
|
||||
}, [handleKeyPress]);
|
||||
|
||||
// Volume control with mouse wheel
|
||||
useEffect(() => {
|
||||
const handleMouseWheel = (event: WheelEvent) => {
|
||||
if (event.deltaY < 0) {
|
||||
@@ -286,46 +326,47 @@ function VideoPlayer() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Set playing state to true when a new item is loaded
|
||||
useLayoutEffect(() => {
|
||||
setPlaying(true);
|
||||
setIsReady(false);
|
||||
}, [item?.Id]);
|
||||
|
||||
const reactPlayerCaptions: TrackProps = useMemo(() => {
|
||||
if (
|
||||
(mediaSource.subtitle.format === "vtt" ||
|
||||
mediaSource.subtitle.format === "subrip") &&
|
||||
mediaSource.subtitle.enable
|
||||
) {
|
||||
return [
|
||||
{
|
||||
kind: "subtitles",
|
||||
src: `${api.basePath}${mediaSource.subtitle.url}`,
|
||||
srcLang: "en",
|
||||
default: true,
|
||||
label: mediaSource.subtitle.url,
|
||||
},
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}, [mediaSource.subtitle.track, mediaSource.subtitle.enable]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(mediaSource.subtitle);
|
||||
if (player.current?.getInternalPlayer() && mediaSource.subtitle.enable) {
|
||||
let jassubRenderer: JASSUB | undefined;
|
||||
if (
|
||||
mediaSource.subtitle.format === "ass" ||
|
||||
mediaSource.subtitle.format === "ssa"
|
||||
) {
|
||||
const jassubRenderer = new JASSUB({
|
||||
jassubRenderer = new JASSUB({
|
||||
//@ts-ignore
|
||||
video: player.current?.getInternalPlayer(),
|
||||
workerUrl,
|
||||
wasmUrl,
|
||||
subUrl: `${api.basePath}${mediaSource.subtitle.url}`,
|
||||
availableFonts: { "noto sans": font },
|
||||
fallbackFont: "noto sans",
|
||||
});
|
||||
return () => jassubRenderer.destroy(); // Remove JASSUB renderer when track changes to fix duplicate renders
|
||||
} else if (
|
||||
mediaSource.subtitle.format === "subrip" ||
|
||||
mediaSource.subtitle.format === "vtt"
|
||||
) {
|
||||
// @ts-ignore internalPlayer here provides the HTML video player element
|
||||
const videoElem: HTMLMediaElement =
|
||||
player.current.getInternalPlayer() as HTMLMediaElement;
|
||||
addSubtitleTrackToReactPlayer(
|
||||
player.current.getInternalPlayer() as HTMLMediaElement,
|
||||
mediaSource.subtitle,
|
||||
api.basePath,
|
||||
);
|
||||
console.log(videoElem.textTracks);
|
||||
}
|
||||
return () => {
|
||||
if (jassubRenderer) {
|
||||
jassubRenderer.destroy();
|
||||
} // Remove JASSUB renderer when track changes to fix duplicate renders
|
||||
};
|
||||
}
|
||||
}, [
|
||||
mediaSource.subtitle.track,
|
||||
@@ -530,13 +571,26 @@ function VideoPlayer() {
|
||||
}, [volume]);
|
||||
|
||||
const handlePlaybackEnded = () => {
|
||||
//check if next track item exists
|
||||
if (queue[currentQueueItemIndex + 1].Id) {
|
||||
playItemFromQueue("next", user?.Id, api);
|
||||
} else {
|
||||
handleExitPlayer(); // Exit player if playback has finished and the queue is empty
|
||||
}
|
||||
};
|
||||
|
||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||
const handleSubtitleChange = (
|
||||
e: ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>,
|
||||
) => {
|
||||
startSubtitleChange(() => {
|
||||
if (mediaSource.subtitle.allTracks) {
|
||||
changeSubtitleTrack(
|
||||
toNumber(e.target.value),
|
||||
mediaSource.subtitle.allTracks,
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="video-player">
|
||||
@@ -672,16 +726,9 @@ function VideoPlayer() {
|
||||
label="Subtitles"
|
||||
variant="outlined"
|
||||
value={mediaSource.subtitle.track}
|
||||
onChange={(e) => {
|
||||
if (mediaSource.subtitle.allTracks) {
|
||||
changeSubtitleTrack(
|
||||
toNumber(e.target.value),
|
||||
mediaSource.subtitle.allTracks,
|
||||
);
|
||||
}
|
||||
}}
|
||||
onChange={handleSubtitleChange}
|
||||
fullWidth
|
||||
disabled={mediaSource.subtitle.track === -2}
|
||||
disabled={mediaSource.subtitle.track === -2 || subtitleIsChanging}
|
||||
>
|
||||
<MenuItem key={-1} value={-1}>
|
||||
No Subtitle
|
||||
@@ -854,8 +901,10 @@ function VideoPlayer() {
|
||||
</IconButton>
|
||||
<QueueButton />
|
||||
<IconButton
|
||||
disabled={mediaSource.subtitle.track === -2}
|
||||
onClick={toggleSubtitleTrack}
|
||||
disabled={
|
||||
mediaSource.subtitle.track === -2 || subtitleIsChanging
|
||||
}
|
||||
onClick={() => startSubtitleChange(toggleSubtitleTrack)}
|
||||
>
|
||||
<span className={"material-symbols-rounded"}>
|
||||
{mediaSource.subtitle.enable
|
||||
@@ -882,7 +931,7 @@ function VideoPlayer() {
|
||||
)}
|
||||
</motion.div>
|
||||
<ReactPlayer
|
||||
key={item?.Id}
|
||||
key={`${item?.Id}${mediaSource.id}`}
|
||||
playing={playing}
|
||||
url={playbackStream}
|
||||
ref={player}
|
||||
@@ -900,18 +949,18 @@ function VideoPlayer() {
|
||||
position: "fixed",
|
||||
zIndex: 1,
|
||||
}}
|
||||
config={{
|
||||
file: {
|
||||
attributes: {
|
||||
crossOrigin: "true",
|
||||
},
|
||||
tracks: reactPlayerCaptions,
|
||||
},
|
||||
}}
|
||||
volume={muted ? 0 : volume}
|
||||
onReady={handleReady}
|
||||
onBuffer={() => setLoading(true)}
|
||||
onBufferEnd={() => setLoading(false)}
|
||||
config={{
|
||||
file: {
|
||||
attributes: {
|
||||
crossOrigin: "anonymous",
|
||||
},
|
||||
tracks: [],
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ function PhotosPlayer() {
|
||||
<img
|
||||
src={
|
||||
item.Id
|
||||
? getImageUrlsApi(api).getItemImageUrl(item.Id, "Primary", {
|
||||
? getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
||||
// width: 250,
|
||||
fillWidth: 250,
|
||||
quality: 70,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
&-name {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5em;
|
||||
margin-left: 1.2em;
|
||||
&-logo {
|
||||
width: 16em;
|
||||
@@ -15,7 +16,6 @@
|
||||
object-position: left top;
|
||||
filter: drop-shadow(0 0 10px black);
|
||||
}
|
||||
gap: 0.5em;
|
||||
}
|
||||
&-trick-bubble {
|
||||
overflow: hidden;
|
||||
@@ -97,12 +97,12 @@ video {
|
||||
gap: 0.2em;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
&-text {
|
||||
margin-bottom: 0.5em;
|
||||
&-text {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: space-between;
|
||||
}
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
&-buttons {
|
||||
display: flex;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { shallow } from "zustand/shallow";
|
||||
import { createWithEqualityFn } from "zustand/traditional";
|
||||
|
||||
interface QueueStore {
|
||||
tracks: BaseItemDto[];
|
||||
tracks: BaseItemDto[] | undefined;
|
||||
currentItemIndex: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user