Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More scene player bug fixes #5379

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
const [fullscreen, setFullscreen] = useState(false);
const [showScrubber, setShowScrubber] = useState(false);

const initialTimestamp = useRef(-1);
const started = useRef(false);
const auto = useRef(false);
const interactiveReady = useRef(false);
Expand Down Expand Up @@ -457,20 +456,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
if (this.currentTime() >= 0.1) {
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) {
Expand All @@ -493,14 +478,12 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
player.on("playing", playing);
player.on("loadstart", loadstart);
player.on("fullscreenchange", fullscreenchange);
player.on("timeupdate", timeupdate);

return () => {
player.off("canplay", canplay);
player.off("playing", playing);
player.off("loadstart", loadstart);
player.off("fullscreenchange", fullscreenchange);
player.off("timeupdate", timeupdate);
};
}, [getPlayer]);

Expand Down Expand Up @@ -675,14 +658,17 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
startPosition = resumeTime;
}

initialTimestamp.current = startPosition;
setTime(startPosition);

player.load();
player.focus();

player.ready(() => {
player.vttThumbnails().src(scene.paths.vtt ?? null);

if (startPosition) {
player.currentTime(startPosition);
}
});

started.current = false;
Expand Down Expand Up @@ -811,7 +797,6 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
if (started.current) {
getPlayer()?.currentTime(seconds);
} else {
initialTimestamp.current = seconds;
setTime(seconds);
}
}
Expand Down
4 changes: 4 additions & 0 deletions ui/v2.5/src/components/ScenePlayer/source-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,12 @@ class SourceSelectorPlugin extends videojs.getPlugin("plugin") {
console.log(`Trying next source in playlist: '${newSource.label}'`);
this.menu.setSelectedSource(newSource);

const currentTime = player.currentTime();
player.src(newSource);
player.load();
player.one("canplay", () => {
player.currentTime(currentTime);
});
player.play();
} else {
console.log("No more sources in playlist");
Expand Down
Loading