mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Preview scrubber (#4022)
* Add sprite info hook * Remove axios dependency * Add preview scrubber * Add scrubber timestamp * On click go to timestamp
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useMemo, useRef } from "react";
|
||||
import { Button, ButtonGroup } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Link, useHistory } from "react-router-dom";
|
||||
import cx from "classnames";
|
||||
import * as GQL from "src/core/generated-graphql";
|
||||
import { Icon } from "../Shared/Icon";
|
||||
@@ -25,12 +25,15 @@ import {
|
||||
faTag,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { objectPath, objectTitle } from "src/core/files";
|
||||
import { PreviewScrubber } from "./PreviewScrubber";
|
||||
|
||||
interface IScenePreviewProps {
|
||||
isPortrait: boolean;
|
||||
image?: string;
|
||||
video?: string;
|
||||
soundActive: boolean;
|
||||
vttPath?: string;
|
||||
onScrubberClick?: (timestamp: number) => void;
|
||||
}
|
||||
|
||||
export const ScenePreview: React.FC<IScenePreviewProps> = ({
|
||||
@@ -38,6 +41,8 @@ export const ScenePreview: React.FC<IScenePreviewProps> = ({
|
||||
video,
|
||||
isPortrait,
|
||||
soundActive,
|
||||
vttPath,
|
||||
onScrubberClick,
|
||||
}) => {
|
||||
const videoEl = useRef<HTMLVideoElement>(null);
|
||||
|
||||
@@ -72,6 +77,7 @@ export const ScenePreview: React.FC<IScenePreviewProps> = ({
|
||||
ref={videoEl}
|
||||
src={video}
|
||||
/>
|
||||
<PreviewScrubber vttPath={vttPath} onClick={onScrubberClick} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -90,6 +96,7 @@ interface ISceneCardProps {
|
||||
export const SceneCard: React.FC<ISceneCardProps> = (
|
||||
props: ISceneCardProps
|
||||
) => {
|
||||
const history = useHistory();
|
||||
const { configuration } = React.useContext(ConfigurationContext);
|
||||
|
||||
const file = useMemo(
|
||||
@@ -383,6 +390,18 @@ export const SceneCard: React.FC<ISceneCardProps> = (
|
||||
})
|
||||
: `/scenes/${props.scene.id}`;
|
||||
|
||||
function onScrubberClick(timestamp: number) {
|
||||
const link = props.queue
|
||||
? props.queue.makeLink(props.scene.id, {
|
||||
sceneIndex: props.index,
|
||||
continue: cont,
|
||||
start: timestamp,
|
||||
})
|
||||
: `/scenes/${props.scene.id}?t=${timestamp}`;
|
||||
|
||||
history.push(link);
|
||||
}
|
||||
|
||||
return (
|
||||
<GridCard
|
||||
className={`scene-card ${zoomIndex()} ${filelessClass()}`}
|
||||
@@ -404,6 +423,8 @@ export const SceneCard: React.FC<ISceneCardProps> = (
|
||||
video={props.scene.paths.preview ?? undefined}
|
||||
isPortrait={isPortrait()}
|
||||
soundActive={configuration?.interface?.soundOnPreview ?? false}
|
||||
vttPath={props.scene.paths.vtt ?? undefined}
|
||||
onScrubberClick={onScrubberClick}
|
||||
/>
|
||||
<RatingBanner rating={props.scene.rating100} />
|
||||
{maybeRenderSceneSpecsOverlay()}
|
||||
|
||||
Reference in New Issue
Block a user