fix: video player takes long time to load #473

This commit is contained in:
Prayag Prajapati committed 2024-12-28 14:13:06 +05:30
1 parent 295b8da8eb
commit 412e54fd82
2 files changed
+15 -4

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="http://localhost:8097"></script> <!-- <script src="http://localhost:8097"></script> -->
<title>Blink</title> <title>Blink</title>
<style> <style>
.app-loading { .app-loading {
+14 -3
View File
@@ -13,7 +13,7 @@ import MenuItem from "@mui/material/MenuItem";
import Slider from "@mui/material/Slider"; import Slider from "@mui/material/Slider";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import ReactPlayer from "react-player"; import ReactPlayer from "react-player/lazy";
import { import {
changeAudioTrack, changeAudioTrack,
@@ -217,6 +217,7 @@ function VideoPlayer() {
const handleReady = async () => { const handleReady = async () => {
if (api && !isReady) { if (api && !isReady) {
player.current?.seekTo(ticksToSec(startPosition), "seconds"); player.current?.seekTo(ticksToSec(startPosition), "seconds");
console.log("Seeking to", ticksToSec(startPosition));
setIsReady(true); setIsReady(true);
// Report Jellyfin server: Playback has begin // Report Jellyfin server: Playback has begin
getPlaystateApi(api).reportPlaybackStart({ getPlaystateApi(api).reportPlaybackStart({
@@ -567,7 +568,8 @@ function VideoPlayer() {
}; };
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString(); const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
const imageAspectRatio = trickplayResolution.Width / trickplayResolution.Height; const imageAspectRatio =
trickplayResolution.Width / trickplayResolution.Height;
if (currentChapter?.[0]?.Name) { if (currentChapter?.[0]?.Name) {
return ( return (
@@ -655,7 +657,10 @@ function VideoPlayer() {
(e) => { (e) => {
startSubtitleChange(() => { startSubtitleChange(() => {
if (mediaSource.subtitle.allTracks) { if (mediaSource.subtitle.allTracks) {
changeSubtitleTrack(toNumber(e.target.value), mediaSource.subtitle.allTracks); changeSubtitleTrack(
toNumber(e.target.value),
mediaSource.subtitle.allTracks,
);
setSettingsMenu(null); setSettingsMenu(null);
} }
}); });
@@ -984,6 +989,7 @@ function VideoPlayer() {
"seconds", "seconds",
); );
} else { } else {
console.log("Seeking to", ticksToSec(newValue));
player.current?.seekTo(ticksToSec(newValue), "seconds"); player.current?.seekTo(ticksToSec(newValue), "seconds");
} }
}} }}
@@ -1206,6 +1212,9 @@ function VideoPlayer() {
console.error(hls); console.error(hls);
console.error(hlsG); console.error(hlsG);
}} }}
onSeek={(e) => {
console.log("Seeking to in Player", e);
}}
onEnded={handlePlaybackEnded} onEnded={handlePlaybackEnded}
width="100vw" width="100vw"
height="100vh" height="100vh"
@@ -1217,10 +1226,12 @@ function VideoPlayer() {
onReady={handleReady} onReady={handleReady}
onBuffer={() => setLoading(true)} onBuffer={() => setLoading(true)}
onBufferEnd={() => setLoading(false)} onBufferEnd={() => setLoading(false)}
playsinline
config={{ config={{
file: { file: {
attributes: { attributes: {
crossOrigin: "anonymous", crossOrigin: "anonymous",
preload: "metadata",
}, },
tracks: [], tracks: [],
}, },