diff --git a/packages/fakeyou.com/src/components/common/LoadingSpinner/LoadingSpinner.tsx b/packages/fakeyou.com/src/components/common/LoadingSpinner/LoadingSpinner.tsx index e5d1697afa..f83b40ff55 100644 --- a/packages/fakeyou.com/src/components/common/LoadingSpinner/LoadingSpinner.tsx +++ b/packages/fakeyou.com/src/components/common/LoadingSpinner/LoadingSpinner.tsx @@ -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 (
Loading...
+ {label &&
{label}
}
); } diff --git a/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx b/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx index 343ee9fa50..5ebe3d59c8 100644 --- a/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx +++ b/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx @@ -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(null); const playbarRef = useRef(null); const trimZoneRef = useRef(null); - const [{playbarWidth, timeCursorOffset}, setPlaybarState] = useState(initialPlaybarState); - const [playpause, setPlaypause] = useState<'playing'|'paused'|'stopped'>('paused'); + const [{ playbarWidth, timeCursorOffset }, setPlaybarState] = + useState(initialPlaybarState); + const [playpause, setPlaypause] = useState<"playing" | "paused" | "stopped">( + "paused" + ); const [isMuted, setIsMuted] = useState(false); - const [{ - canNotTrim, - trimStart, - // trimEnd, - trimDuration, - // isScrubbingTrim, - }, setTrimState] = useState(initialTrimState); - + const [ + { + canNotTrim, + trimStart, + // trimEnd, + trimDuration, + // isScrubbingTrim, + }, + setTrimState, + ] = useState(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({ />
- {playpause === 'paused' && - - } - {playpause === 'playing' && - - } + )}
- {videoRef.current && canNotTrim && + {videoRef.current && canNotTrim && (

Warning: Sorry Your Video is TOO Short

- } - {/* END of Video Wrapper */} + )} + + {/* END of Video Wrapper */}
-
{ // if(trimZoneRef.current){ // trimZoneRef.current.style.cursor = 'grabbing'; @@ -220,14 +231,14 @@ export default memo(function VideoQuickTrim({ >
-
-
{/* END of Playbar */} - +
+
{" "} + {/* END of Playbar */}
diff --git a/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss b/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss index 9c30de85ca..00a437cc6f 100644 --- a/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss +++ b/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss @@ -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; } } } -} \ No newline at end of file +} diff --git a/packages/fakeyou.com/src/v2/view/PageContainer.tsx b/packages/fakeyou.com/src/v2/view/PageContainer.tsx index a5c0fa78c8..73c2c0820e 100644 --- a/packages/fakeyou.com/src/v2/view/PageContainer.tsx +++ b/packages/fakeyou.com/src/v2/view/PageContainer.tsx @@ -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< /> + + + + diff --git a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntro.scss b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntro.scss index 22a48fca59..d5314fae00 100644 --- a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntro.scss +++ b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntro.scss @@ -3,3 +3,7 @@ flex-direction: column; height: calc(100vh - 66px); } + +.result-video-wrapper { + max-width: 1100px; +} diff --git a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroPage.tsx b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroPage.tsx index ec60816227..98b020d084 100644 --- a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroPage.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroPage.tsx @@ -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 || "", diff --git a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroResultPage.tsx b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroResultPage.tsx new file mode 100644 index 0000000000..e1cd967d77 --- /dev/null +++ b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioIntroResultPage.tsx @@ -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(null); + + const [mediaFile, setMediaFile] = useState(); + + 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 ( + + +

Generation Result

+
+ +
+ {mediaToken ? ( +
+
+ {mediaToken ? ( +
+
+ ) : null} +
+ ); +} + +export { StudioIntroResultPage }; diff --git a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioVST/StudioVSTPage.tsx b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioVST/StudioVSTPage.tsx index e96a6e9057..4a8f5a0bef 100644 --- a/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioVST/StudioVSTPage.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/storyteller_studio_intro/StudioVST/StudioVSTPage.tsx @@ -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(); + const { jobToken } = useParams<{ jobToken: string }>(); const videoRef = useRef(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(null); const [vstValues, setVstValues] = useState({ ...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 ( + +

Style Your Scene

+
-
+
- - handleOnChange({ - trimStart: val.trimStartSeconds, - trimEnd: val.trimEndSeconds, - }) - } - /> + {vstValues.fileToken ? ( + + handleOnChange({ + trimStart: val.trimStartSeconds, + trimEnd: val.trimEndSeconds, + }) + } + /> + ) : ( +
+ +
+ )}
-
+