mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 06:42:14 +00:00
studio intro pages
This commit is contained in:
1 parent
e61215f5d5
commit
8acd91ee1f
9 files changed
+305
-166
No files matched your search
@@ -2,18 +2,23 @@ import React from "react";
|
||||
|
||||
interface LoadingSpinnerProps {
|
||||
className?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export default function LoadingSpinner({ className }: LoadingSpinnerProps) {
|
||||
export default function LoadingSpinner({
|
||||
className,
|
||||
label,
|
||||
}: LoadingSpinnerProps) {
|
||||
return (
|
||||
<div
|
||||
className={`pt-2 d-flex justify-content-center overflow-hidden ${
|
||||
className={`pt-2 d-flex justify-content-center align-items-center overflow-hidden gap-3 ${
|
||||
className ? className : ""
|
||||
}`.trim()}
|
||||
>
|
||||
<div className="spinner-border text-light" role="status">
|
||||
<span className="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{label && <div className="fw-medium">{label}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -12,149 +12,154 @@ import {
|
||||
faGripDots,
|
||||
faVolume,
|
||||
faVolumeSlash,
|
||||
} from "@fortawesome/pro-solid-svg-icons"
|
||||
} from "@fortawesome/pro-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import {
|
||||
Button,
|
||||
SelectionBubbles,
|
||||
VideoFakeyou
|
||||
} from "components/common";
|
||||
import { Button, SelectionBubbles, VideoFakeyou } from "components/common";
|
||||
import { VideoFakeyouProps } from "../VideoFakeyou/VideoFakeyou";
|
||||
|
||||
import { QuickTrimData, TrimStates, PlaybarStates } from "./types";
|
||||
import { formatSecondsToHHMMSSCS } from "./helpers";
|
||||
import './styles.scss'
|
||||
import "./styles.scss";
|
||||
|
||||
interface VideoQuickTrimProps extends VideoFakeyouProps{
|
||||
onSelect: (values: QuickTrimData)=>void;
|
||||
interface VideoQuickTrimProps extends VideoFakeyouProps {
|
||||
onSelect: (values: QuickTrimData) => void;
|
||||
}
|
||||
|
||||
const trimOptions: { [key: string]: number } = {
|
||||
"3s": 3,
|
||||
"5s": 5,
|
||||
"10s": 10,
|
||||
"15s" : 15,
|
||||
"15s": 15,
|
||||
};
|
||||
|
||||
const initialTrimState:TrimStates = {
|
||||
const initialTrimState: TrimStates = {
|
||||
canNotTrim: true,
|
||||
isScrubbingTrim: false,
|
||||
trimDuration: 0,
|
||||
trimStart: 0,
|
||||
trimEnd: 0,
|
||||
maxDuration: 0,
|
||||
}
|
||||
};
|
||||
|
||||
const initialPlaybarState:PlaybarStates = {
|
||||
const initialPlaybarState: PlaybarStates = {
|
||||
playbarWidth: 0,
|
||||
timeCursorOffset: 0,
|
||||
}
|
||||
};
|
||||
|
||||
export default memo(function VideoQuickTrim({
|
||||
onSelect,
|
||||
...rest
|
||||
}: VideoQuickTrimProps){
|
||||
}: VideoQuickTrimProps) {
|
||||
// console.log("VideoQuickTrim Rerender!!");
|
||||
|
||||
const videoRef = useRef<HTMLVideoElement | null>(null);
|
||||
const playbarRef = useRef<HTMLDivElement | null>(null);
|
||||
const trimZoneRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [{playbarWidth, timeCursorOffset}, setPlaybarState] = useState<PlaybarStates>(initialPlaybarState);
|
||||
const [playpause, setPlaypause] = useState<'playing'|'paused'|'stopped'>('paused');
|
||||
const [{ playbarWidth, timeCursorOffset }, setPlaybarState] =
|
||||
useState<PlaybarStates>(initialPlaybarState);
|
||||
const [playpause, setPlaypause] = useState<"playing" | "paused" | "stopped">(
|
||||
"paused"
|
||||
);
|
||||
const [isMuted, setIsMuted] = useState<boolean>(false);
|
||||
const [{
|
||||
canNotTrim,
|
||||
trimStart,
|
||||
// trimEnd,
|
||||
trimDuration,
|
||||
// isScrubbingTrim,
|
||||
}, setTrimState] = useState<TrimStates>(initialTrimState);
|
||||
|
||||
const [
|
||||
{
|
||||
canNotTrim,
|
||||
trimStart,
|
||||
// trimEnd,
|
||||
trimDuration,
|
||||
// isScrubbingTrim,
|
||||
},
|
||||
setTrimState,
|
||||
] = useState<TrimStates>(initialTrimState);
|
||||
|
||||
const videoRefCallback = useCallback(
|
||||
node => {
|
||||
if (node !== null) {
|
||||
// DOM node referenced by ref has changed and exists
|
||||
videoRef.current = node;
|
||||
|
||||
const videoRefCallback = useCallback(node => {
|
||||
if (node !== null) {
|
||||
// DOM node referenced by ref has changed and exists
|
||||
videoRef.current = node;
|
||||
|
||||
node.onloadedmetadata = ()=>{
|
||||
if (node.duration >= 3){
|
||||
setTrimState((curr)=>({
|
||||
node.onloadedmetadata = () => {
|
||||
if (node.duration >= 3) {
|
||||
setTrimState(curr => ({
|
||||
...curr,
|
||||
canNotTrim: false,
|
||||
trimDuration: 3,
|
||||
trimEnd: 3,
|
||||
maxDuration: node.duration,
|
||||
}));
|
||||
onSelect({
|
||||
trimStartSeconds: 0,
|
||||
trimEndSeconds: 3,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
node.ontimeupdate = (e: PointerEvent) => {
|
||||
setPlaybarState(curr => ({
|
||||
...curr,
|
||||
canNotTrim: false,
|
||||
trimDuration: 3,
|
||||
trimEnd: 3,
|
||||
maxDuration: node.duration
|
||||
timeCursorOffset:
|
||||
(node.currentTime / node.duration) * (playbarWidth - 8),
|
||||
}));
|
||||
onSelect({
|
||||
trimStartSeconds: 0,
|
||||
trimEndSeconds: 3,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
node.ontimeupdate = (e: PointerEvent)=>{
|
||||
setPlaybarState((curr)=>({
|
||||
...curr,
|
||||
timeCursorOffset: (node.currentTime / node.duration) * (playbarWidth-8)
|
||||
}));
|
||||
}
|
||||
} // else{} DOM node referenced by ref has been unmounted
|
||||
}, [playbarWidth, onSelect]); //END videoRefCallback
|
||||
};
|
||||
} // else{} DOM node referenced by ref has been unmounted
|
||||
},
|
||||
[playbarWidth, onSelect]
|
||||
); //END videoRefCallback
|
||||
|
||||
function handleWindowResize() {
|
||||
if(playbarRef.current !== null){
|
||||
if (playbarRef.current !== null) {
|
||||
const newWidth = playbarRef.current.getBoundingClientRect().width;
|
||||
setPlaybarState((curr)=>({
|
||||
setPlaybarState(curr => ({
|
||||
playbarWidth: newWidth,
|
||||
timeCursorOffset: (curr.timeCursorOffset / (curr.playbarWidth-8)) * (newWidth-8)
|
||||
timeCursorOffset:
|
||||
(curr.timeCursorOffset / (curr.playbarWidth - 8)) * (newWidth - 8),
|
||||
}));
|
||||
}
|
||||
}
|
||||
const playbarRefCallback = useCallback(node => {
|
||||
if(node !== null) {
|
||||
if (node !== null) {
|
||||
playbarRef.current = node;
|
||||
setPlaybarState((curr)=>({
|
||||
setPlaybarState(curr => ({
|
||||
...curr,
|
||||
playbarWidth: node.getBoundingClientRect().width
|
||||
playbarWidth: node.getBoundingClientRect().width,
|
||||
}));
|
||||
}
|
||||
}, []);
|
||||
useLayoutEffect(()=>{
|
||||
window.addEventListener('resize', handleWindowResize);
|
||||
useLayoutEffect(() => {
|
||||
window.addEventListener("resize", handleWindowResize);
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleWindowResize);
|
||||
window.removeEventListener("resize", handleWindowResize);
|
||||
};
|
||||
},[]);
|
||||
}, []);
|
||||
|
||||
const handleChangeTrimDuration = (selected: string) =>{
|
||||
if(!canNotTrim){
|
||||
setTrimState((curr)=>({
|
||||
const handleChangeTrimDuration = (selected: string) => {
|
||||
if (!canNotTrim) {
|
||||
setTrimState(curr => ({
|
||||
...curr,
|
||||
trimDuration: trimOptions[selected],
|
||||
trimEnd: trimStart+ trimOptions[selected],
|
||||
}))
|
||||
trimEnd: trimStart + trimOptions[selected],
|
||||
}));
|
||||
onSelect({
|
||||
trimStartSeconds: trimStart,
|
||||
trimEndSeconds: trimStart+ trimOptions[selected],
|
||||
trimEndSeconds: trimStart + trimOptions[selected],
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handlePlaypause = ()=>{
|
||||
if (playpause === 'paused' || playpause === 'stopped'){
|
||||
const handlePlaypause = () => {
|
||||
if (playpause === "paused" || playpause === "stopped") {
|
||||
videoRef.current?.play();
|
||||
setPlaypause('playing');
|
||||
}else{
|
||||
setPlaypause("playing");
|
||||
} else {
|
||||
videoRef.current?.pause();
|
||||
setPlaypause('paused');
|
||||
setPlaypause("paused");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const trimZoneWidth = videoRef.current
|
||||
? trimDuration > 0 && trimDuration < videoRef.current.duration
|
||||
? (trimDuration / videoRef.current.duration * 100)
|
||||
const trimZoneWidth = videoRef.current
|
||||
? trimDuration > 0 && trimDuration < videoRef.current.duration
|
||||
? (trimDuration / videoRef.current.duration) * 100
|
||||
: 100
|
||||
: 0;
|
||||
|
||||
@@ -169,29 +174,35 @@ export default memo(function VideoQuickTrim({
|
||||
/>
|
||||
|
||||
<div className="playpause-overlay" onClick={handlePlaypause}>
|
||||
{playpause === 'paused' &&
|
||||
<FontAwesomeIcon className="playpause-icon"
|
||||
icon={faPlay} size="8x"
|
||||
{playpause === "paused" && (
|
||||
<FontAwesomeIcon
|
||||
className="playpause-icon"
|
||||
icon={faPlay}
|
||||
size="8x"
|
||||
/>
|
||||
}
|
||||
{playpause === 'playing' &&
|
||||
<FontAwesomeIcon className="playpause-icon"
|
||||
icon={faPause} size="8x"
|
||||
)}
|
||||
{playpause === "playing" && (
|
||||
<FontAwesomeIcon
|
||||
className="playpause-icon"
|
||||
icon={faPause}
|
||||
size="8x"
|
||||
/>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
{videoRef.current && canNotTrim &&
|
||||
{videoRef.current && canNotTrim && (
|
||||
<div className="warning-too-short">
|
||||
<div className="background"></div>
|
||||
<p>Warning: Sorry Your Video is TOO Short</p>
|
||||
</div>
|
||||
}
|
||||
</div>{/* END of Video Wrapper */}
|
||||
)}
|
||||
</div>
|
||||
{/* END of Video Wrapper */}
|
||||
<div className="playbar" ref={playbarRefCallback}>
|
||||
<div className="playbar-bg" />
|
||||
<div className="trimzone"
|
||||
<div
|
||||
className="trimzone"
|
||||
ref={trimZoneRef}
|
||||
style={{width: trimZoneWidth + "%"}}
|
||||
style={{ width: trimZoneWidth + "%" }}
|
||||
// onPointerDown={()=>{
|
||||
// if(trimZoneRef.current){
|
||||
// trimZoneRef.current.style.cursor = 'grabbing';
|
||||
@@ -220,14 +231,14 @@ export default memo(function VideoQuickTrim({
|
||||
>
|
||||
<FontAwesomeIcon icon={faGripDots} />
|
||||
</div>
|
||||
<div className="playcursor" style={{left: timeCursorOffset+"px"}}/>
|
||||
</div> {/* END of Playbar */}
|
||||
|
||||
<div className="playcursor" style={{ left: timeCursorOffset + "px" }} />
|
||||
</div>{" "}
|
||||
{/* END of Playbar */}
|
||||
<div className="d-flex w-100 justify-content-between mt-3 flex-wrap">
|
||||
<div className="playpause-external d-flex align-items-center flex-wrap mb-2">
|
||||
<Button
|
||||
className="button-playpause"
|
||||
icon={playpause === 'playing' ? faPause : faPlay}
|
||||
icon={playpause === "playing" ? faPause : faPlay}
|
||||
variant="secondary"
|
||||
onClick={handlePlaypause}
|
||||
/>
|
||||
@@ -235,12 +246,14 @@ export default memo(function VideoQuickTrim({
|
||||
className="button-mute"
|
||||
icon={isMuted ? faVolumeSlash : faVolume}
|
||||
variant="secondary"
|
||||
onClick={()=>setIsMuted((curr)=>(!curr))}
|
||||
onClick={() => setIsMuted(curr => !curr)}
|
||||
/>
|
||||
<div className="playtime ms-2 d-flex">
|
||||
<span >
|
||||
<span>
|
||||
<p>
|
||||
{`${formatSecondsToHHMMSSCS(videoRef.current?.currentTime || 0)}`}
|
||||
{`${formatSecondsToHHMMSSCS(
|
||||
videoRef.current?.currentTime || 0
|
||||
)}`}
|
||||
</p>
|
||||
</span>
|
||||
<div>/</div>
|
||||
@@ -254,6 +267,7 @@ export default memo(function VideoQuickTrim({
|
||||
<SelectionBubbles
|
||||
options={Object.keys(trimOptions)}
|
||||
onSelect={handleChangeTrimDuration}
|
||||
selectedStyle="outline"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
$playbar-height: 2rem;
|
||||
|
||||
.fy-video-quicktrim {
|
||||
.video-wrapper{
|
||||
.video-wrapper {
|
||||
position: relative;
|
||||
background-color: $bg;
|
||||
border-radius: 0.5rem 0.5rem 0 0;
|
||||
@@ -11,71 +11,76 @@ $playbar-height: 2rem;
|
||||
border-left: $panel-inner-border 1px solid;
|
||||
border-right: $panel-inner-border 1px solid;
|
||||
}
|
||||
.fy-video{
|
||||
height: 500px;
|
||||
.fy-video {
|
||||
max-height: 500px;
|
||||
margin-bottom: -7px;
|
||||
|
||||
video {
|
||||
border-radius: 0.5rem 0.5rem 0 0;
|
||||
}
|
||||
}
|
||||
.playpause-overlay{
|
||||
.playpause-overlay {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
top:0;
|
||||
left:0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
svg{
|
||||
svg {
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s;
|
||||
transition: opacity 0.5s;
|
||||
}
|
||||
&:hover svg{
|
||||
&:hover svg {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.warning-too-short{
|
||||
.warning-too-short {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
top:0;
|
||||
left:0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
div{
|
||||
div {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
top:0;
|
||||
left:0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: #e66462;
|
||||
opacity: 70%;
|
||||
}
|
||||
p{
|
||||
p {
|
||||
position: absolute;
|
||||
margin-top: 230px;
|
||||
width: 100%;
|
||||
top:0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
.playbar{
|
||||
position:relative;
|
||||
.playbar {
|
||||
position: relative;
|
||||
height: $playbar-height;
|
||||
width: 100%;
|
||||
}
|
||||
.playbar-bg{
|
||||
.playbar-bg {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
top:0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: $panel-inner-border;
|
||||
border-radius: 0 0 0.5rem 0.5rem;
|
||||
}
|
||||
.trimzone{
|
||||
.trimzone {
|
||||
position: absolute;
|
||||
top:-1rem;
|
||||
top: -1rem;
|
||||
height: 3rem;
|
||||
background-color: #e66462;
|
||||
opacity: 0.8;
|
||||
@@ -92,29 +97,29 @@ $playbar-height: 2rem;
|
||||
color: $panel-inner-border;
|
||||
}
|
||||
}
|
||||
.playcursor{
|
||||
.playcursor {
|
||||
position: absolute;
|
||||
top:0;
|
||||
top: 0;
|
||||
width: 0.5rem;
|
||||
height: $playbar-height;
|
||||
background-color: $white;
|
||||
}
|
||||
|
||||
.playpause-external{
|
||||
.button-playpause{
|
||||
.playpause-external {
|
||||
.button-playpause {
|
||||
width: 55px;
|
||||
height: 40px;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
.button-mute{
|
||||
.button-mute {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
.playtime{
|
||||
span{
|
||||
.playtime {
|
||||
span {
|
||||
width: 60px;
|
||||
}
|
||||
div{
|
||||
div {
|
||||
width: 10px;
|
||||
margin-left: 3px;
|
||||
margin-right: 5px;
|
||||
@@ -122,4 +127,4 @@ $playbar-height: 2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,6 +125,7 @@ import DevUpload from "./pages/dev_upload/DevUpload";
|
||||
import DevMediaInput from "./pages/dev_upload/DevMediaInput";
|
||||
import { StudioIntroPage } from "./pages/storyteller_studio_intro/StudioIntroPage";
|
||||
import StudioVSTPage from "./pages/storyteller_studio_intro/StudioVST/StudioVSTPage";
|
||||
import { StudioIntroResultPage } from "./pages/storyteller_studio_intro/StudioIntroResultPage";
|
||||
|
||||
interface Props {
|
||||
sessionWrapper: SessionWrapper;
|
||||
@@ -757,6 +758,15 @@ class PageContainer extends React.Component<
|
||||
/>
|
||||
</Route>
|
||||
|
||||
<Route path="/studio-intro/result/:jobToken?">
|
||||
<StudioIntroResultPage
|
||||
sessionWrapper={this.props.sessionWrapper}
|
||||
sessionSubscriptionsWrapper={
|
||||
this.props.sessionSubscriptionsWrapper
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
|
||||
<Route path="/studio-intro/style/:jobToken?">
|
||||
<StudioVSTPage />
|
||||
</Route>
|
||||
|
||||
@@ -3,3 +3,7 @@
|
||||
flex-direction: column;
|
||||
height: calc(100vh - 66px);
|
||||
}
|
||||
|
||||
.result-video-wrapper {
|
||||
max-width: 1100px;
|
||||
}
|
||||
@@ -42,6 +42,7 @@ function StudioIntroPage(props: Props) {
|
||||
}
|
||||
|
||||
const onClick = () => {
|
||||
// This opens the job modal. Needs to be disabled.
|
||||
EnqueueEngineCompositing("", {
|
||||
uuid_idempotency_token: uuidv4(),
|
||||
media_file_token: mediaToken || "",
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import React, { useState } from "react";
|
||||
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
|
||||
import { SessionSubscriptionsWrapper } from "@storyteller/components/src/session/SessionSubscriptionsWrapper";
|
||||
import { Button, Container, Panel } from "components/common";
|
||||
import { usePrefixedDocumentTitle } from "common/UsePrefixedDocumentTitle";
|
||||
import { useHistory, useParams } from "react-router-dom";
|
||||
import "./StudioIntro.scss";
|
||||
import LoadingSpinner from "components/common/LoadingSpinner";
|
||||
import { useMedia } from "hooks";
|
||||
import { BucketConfig } from "@storyteller/components/src/api/BucketConfig";
|
||||
import { MediaFileType } from "@storyteller/components/src/api/media_files";
|
||||
|
||||
interface Props {
|
||||
sessionWrapper: SessionWrapper;
|
||||
sessionSubscriptionsWrapper: SessionSubscriptionsWrapper;
|
||||
}
|
||||
|
||||
// This page just needs to poll the job and show the video when it's done.
|
||||
|
||||
function StudioIntroResultPage(props: Props) {
|
||||
const { jobToken } = useParams<{ jobToken: string }>();
|
||||
const history = useHistory();
|
||||
const [mediaToken, setMediaToken] = useState(
|
||||
"m_f5kp3hm74qeq16eq7536jb73jkbvkh"
|
||||
); // Set the media token after polling success
|
||||
|
||||
// const [jobExists, setJobExists] = useState<boolean | null>(null);
|
||||
|
||||
const [mediaFile, setMediaFile] = useState<MediaFileType>();
|
||||
|
||||
useMedia({
|
||||
mediaToken: mediaToken,
|
||||
onSuccess: (res: any) => {
|
||||
setMediaFile(res);
|
||||
},
|
||||
});
|
||||
|
||||
const mediaLink =
|
||||
mediaFile && new BucketConfig().getGcsUrl(mediaFile.public_bucket_path);
|
||||
|
||||
usePrefixedDocumentTitle("Storyteller Studio");
|
||||
|
||||
if (!jobToken) {
|
||||
history.push("/");
|
||||
}
|
||||
|
||||
// Should also check if job actually exists or not
|
||||
//
|
||||
// if (!jobExists) {
|
||||
// history.push("/");
|
||||
// }
|
||||
|
||||
return (
|
||||
<Container
|
||||
type="full"
|
||||
className="mt-4 d-flex flex-column align-items-center"
|
||||
>
|
||||
<Panel clear={true}>
|
||||
<h2 className="fw-bold mb-0 mb-4 text-center">Generation Result</h2>
|
||||
</Panel>
|
||||
<Panel className="overflow-hidden rounded result-video-wrapper">
|
||||
<div className="ratio ratio-16x9">
|
||||
{mediaToken ? (
|
||||
<video src={mediaLink} controls />
|
||||
) : (
|
||||
<LoadingSpinner label="Generating your movie..." />
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
{mediaToken ? (
|
||||
<div className="d-flex justify-content-center p-4">
|
||||
<Button label="Sign up to use your own scene" />
|
||||
</div>
|
||||
) : null}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
export { StudioIntroResultPage };
|
||||
+54
-33
@@ -13,15 +13,17 @@ import VideoQuickTrim, {
|
||||
import EnqueueVideoStyleTransfer from "@storyteller/components/src/api/video_styleTransfer";
|
||||
import { initialValues } from "./defaultValues";
|
||||
import { mapRequest, VSTType } from "./helpers";
|
||||
import LoadingSpinner from "components/common/LoadingSpinner";
|
||||
// import SectionAdvanceOptions from "./sectionAdvanceOptions";
|
||||
|
||||
export default function PageVSTApp() {
|
||||
const { jobToken } = useParams<any>();
|
||||
const { jobToken } = useParams<{ jobToken: string }>();
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
const history = useHistory();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [mediaToken, setMediaToken] = useState("");
|
||||
|
||||
const [mediaToken, setMediaToken] = useState(
|
||||
"m_wnnz9jey96dwhss9qk1891v9gmvnj8" // Currently hardcoded video media token value. Let a job polling function set the value when job returns media on success.
|
||||
);
|
||||
// const [jobExists, setJobExists] = useState<boolean | null>(null);
|
||||
const [vstValues, setVstValues] = useState<VSTType>({
|
||||
...initialValues,
|
||||
fileToken: mediaToken,
|
||||
@@ -38,7 +40,7 @@ export default function PageVSTApp() {
|
||||
EnqueueVideoStyleTransfer(request).then(res => {
|
||||
if (res.success && res.inference_job_token) {
|
||||
console.log("Job enqueued successfully", res.inference_job_token);
|
||||
history.push(`/jobs`); // Adjusted to use a fixed path
|
||||
history.push(`/studio-intro/result/${res.inference_job_token}`);
|
||||
} else {
|
||||
console.log("Failed to enqueue job", res);
|
||||
}
|
||||
@@ -64,7 +66,7 @@ export default function PageVSTApp() {
|
||||
}
|
||||
|
||||
const styleMap: { [key: string]: string } = {
|
||||
Anime: "weight_yqexh77ntqyawzgh9fzash798",
|
||||
Anime: "weight_yqexh77ntqyawzgh9fzash798", // set SD Model Weight Tokens, currently hardcoded all to Anime style
|
||||
Pixel: "weight_yqexh77ntqyawzgh9fzash798",
|
||||
Painting: "weight_yqexh77ntqyawzgh9fzash798",
|
||||
};
|
||||
@@ -76,37 +78,58 @@ export default function PageVSTApp() {
|
||||
|
||||
const styleOptions = Object.keys(styleMap);
|
||||
|
||||
if (!jobToken) {
|
||||
history.push("/");
|
||||
}
|
||||
|
||||
// Should also check if job actually exists or not
|
||||
//
|
||||
// if (!jobExists) {
|
||||
// history.push("/");
|
||||
// }
|
||||
|
||||
return (
|
||||
<Container type="panel" className="mt-5">
|
||||
<Panel clear={true}>
|
||||
<h2 className="fw-bold mb-0 mb-5 text-center">Style Your Scene</h2>
|
||||
</Panel>
|
||||
<Panel padding={true}>
|
||||
<div className="row g-4">
|
||||
<div className="row g-5">
|
||||
<div className="col-12 col-md-6">
|
||||
<VideoQuickTrim
|
||||
mediaToken={vstValues.fileToken}
|
||||
onSelect={(val: QuickTrimData) =>
|
||||
handleOnChange({
|
||||
trimStart: val.trimStartSeconds,
|
||||
trimEnd: val.trimEndSeconds,
|
||||
})
|
||||
}
|
||||
/>
|
||||
{vstValues.fileToken ? (
|
||||
<VideoQuickTrim
|
||||
mediaToken={vstValues.fileToken}
|
||||
onSelect={(val: QuickTrimData) =>
|
||||
handleOnChange({
|
||||
trimStart: val.trimStartSeconds,
|
||||
trimEnd: val.trimEndSeconds,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div className="ratio ratio-4x3 panel-inner rounded">
|
||||
<LoadingSpinner label="Loading Video" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-12 col-md-6 d-flex flex-column gap-3">
|
||||
<div className="col-12 col-md-6 d-flex flex-column gap-3 justify-content-center">
|
||||
<div>
|
||||
<label className="sub-title">Select a Style</label>
|
||||
<SelectionBubbles
|
||||
options={styleOptions}
|
||||
onSelect={handleStyleSelection}
|
||||
selectedStyle="fill"
|
||||
selectedStyle="outline"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<TextArea
|
||||
label="Prompt"
|
||||
placeholder="Enter your prompt"
|
||||
label="Describe Your Scene"
|
||||
placeholder="Enter your description..."
|
||||
onChange={e => handleOnChange({ posPrompt: e.target.value })}
|
||||
value={vstValues.posPrompt}
|
||||
required={false}
|
||||
rows={5}
|
||||
resize={false}
|
||||
/>
|
||||
{/* <TextArea
|
||||
label="Negative Prompt"
|
||||
@@ -119,19 +142,17 @@ export default function PageVSTApp() {
|
||||
onChange={handleOnChange}
|
||||
vstValues={vstValues}
|
||||
/> */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row g-3 mt-4">
|
||||
<div className="col-12 d-flex justify-content-between">
|
||||
<NavLink to="/">
|
||||
<Button label="Cancel" variant="primary" />
|
||||
</NavLink>
|
||||
<Button
|
||||
label="Enqueue"
|
||||
onClick={handleGenerate}
|
||||
variant="primary"
|
||||
disabled={vstValues.trimEnd === 0}
|
||||
/>
|
||||
<div className="d-flex gap-2 justify-content-end mt-3">
|
||||
<NavLink to="/">
|
||||
<Button label="Cancel" variant="secondary" />
|
||||
</NavLink>
|
||||
<Button
|
||||
label="Generate Your Movie"
|
||||
onClick={handleGenerate}
|
||||
variant="primary"
|
||||
disabled={!vstValues.fileToken}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ const initialValues = {
|
||||
|
||||
//basics
|
||||
inputFps: 24,
|
||||
posPrompt: "perfect anime illustration,(best-quality:0.8),",
|
||||
posPrompt: "",
|
||||
negPrompt: "",
|
||||
visibility: "private",
|
||||
|
||||
|
||||
Reference in new issue
Block a user