mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
More scene player bug fixes (#5379)
* Don't play video when seeking non-started video * Set initial time on load instead of play * Continue playing from current position when switching sources on error * Remove unnecessary ref
This commit is contained in:
@@ -243,7 +243,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
|
|||||||
const [fullscreen, setFullscreen] = useState(false);
|
const [fullscreen, setFullscreen] = useState(false);
|
||||||
const [showScrubber, setShowScrubber] = useState(false);
|
const [showScrubber, setShowScrubber] = useState(false);
|
||||||
|
|
||||||
const initialTimestamp = useRef(-1);
|
|
||||||
const started = useRef(false);
|
const started = useRef(false);
|
||||||
const auto = useRef(false);
|
const auto = useRef(false);
|
||||||
const interactiveReady = useRef(false);
|
const interactiveReady = useRef(false);
|
||||||
@@ -457,20 +456,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
|
|||||||
if (this.currentTime() >= 0.1) {
|
if (this.currentTime() >= 0.1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialTimestamp.current !== -1) {
|
|
||||||
this.currentTime(initialTimestamp.current);
|
|
||||||
initialTimestamp.current = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function timeupdate(this: VideoJsPlayer) {
|
|
||||||
// fired when seeking
|
|
||||||
// check if we haven't started playing yet
|
|
||||||
// if so, start playing
|
|
||||||
if (!started.current) {
|
|
||||||
this.play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function playing(this: VideoJsPlayer) {
|
function playing(this: VideoJsPlayer) {
|
||||||
@@ -493,14 +478,12 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
|
|||||||
player.on("playing", playing);
|
player.on("playing", playing);
|
||||||
player.on("loadstart", loadstart);
|
player.on("loadstart", loadstart);
|
||||||
player.on("fullscreenchange", fullscreenchange);
|
player.on("fullscreenchange", fullscreenchange);
|
||||||
player.on("timeupdate", timeupdate);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
player.off("canplay", canplay);
|
player.off("canplay", canplay);
|
||||||
player.off("playing", playing);
|
player.off("playing", playing);
|
||||||
player.off("loadstart", loadstart);
|
player.off("loadstart", loadstart);
|
||||||
player.off("fullscreenchange", fullscreenchange);
|
player.off("fullscreenchange", fullscreenchange);
|
||||||
player.off("timeupdate", timeupdate);
|
|
||||||
};
|
};
|
||||||
}, [getPlayer]);
|
}, [getPlayer]);
|
||||||
|
|
||||||
@@ -675,7 +658,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
|
|||||||
startPosition = resumeTime;
|
startPosition = resumeTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialTimestamp.current = startPosition;
|
|
||||||
setTime(startPosition);
|
setTime(startPosition);
|
||||||
|
|
||||||
player.load();
|
player.load();
|
||||||
@@ -683,6 +665,10 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
|
|||||||
|
|
||||||
player.ready(() => {
|
player.ready(() => {
|
||||||
player.vttThumbnails().src(scene.paths.vtt ?? null);
|
player.vttThumbnails().src(scene.paths.vtt ?? null);
|
||||||
|
|
||||||
|
if (startPosition) {
|
||||||
|
player.currentTime(startPosition);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
started.current = false;
|
started.current = false;
|
||||||
@@ -811,7 +797,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
|
|||||||
if (started.current) {
|
if (started.current) {
|
||||||
getPlayer()?.currentTime(seconds);
|
getPlayer()?.currentTime(seconds);
|
||||||
} else {
|
} else {
|
||||||
initialTimestamp.current = seconds;
|
|
||||||
setTime(seconds);
|
setTime(seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,8 +196,12 @@ class SourceSelectorPlugin extends videojs.getPlugin("plugin") {
|
|||||||
console.log(`Trying next source in playlist: '${newSource.label}'`);
|
console.log(`Trying next source in playlist: '${newSource.label}'`);
|
||||||
this.menu.setSelectedSource(newSource);
|
this.menu.setSelectedSource(newSource);
|
||||||
|
|
||||||
|
const currentTime = player.currentTime();
|
||||||
player.src(newSource);
|
player.src(newSource);
|
||||||
player.load();
|
player.load();
|
||||||
|
player.one("canplay", () => {
|
||||||
|
player.currentTime(currentTime);
|
||||||
|
});
|
||||||
player.play();
|
player.play();
|
||||||
} else {
|
} else {
|
||||||
console.log("No more sources in playlist");
|
console.log("No more sources in playlist");
|
||||||
|
|||||||
Reference in New Issue
Block a user