From b22379140963949eb1bcce5d1ea40cba88c1727d Mon Sep 17 00:00:00 2001 From: wil Date: Wed, 28 Feb 2024 17:10:07 -0500 Subject: [PATCH 1/2] video duration check properly implemented with on load data --- .../common/VideoQuickTrim/VideoQuickTrim.tsx | 53 +++++++++++-------- .../common/VideoQuickTrim/styles.scss | 17 ++++-- .../components/pageVSTApp/defaultValues.tsx | 4 +- .../components/pageVSTApp/pageVSTApp.tsx | 5 +- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx b/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx index 67e6b0a39c..5933329bac 100644 --- a/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx +++ b/packages/fakeyou.com/src/components/common/VideoQuickTrim/VideoQuickTrim.tsx @@ -77,21 +77,29 @@ export default memo(function VideoQuickTrim({ if (node !== null) { // DOM node referenced by ref has changed and exists videoRef.current = node; - if (node.duration >= 3){ - setTrimState((curr)=>({ - ...curr, - canNotTrim: false, - trimDuration: 3, - trimEnd: 0, - maxDuration: node.duration - })); - node.ontimeupdate = (e: PointerEvent)=>{ - setPlaybarState((curr)=>({ + + node.onloadedmetadata = ()=>{ + if (node.duration >= 3){ + setTrimState((curr)=>({ ...curr, - timeCursorOffset: (node.currentTime / node.duration) * (playbarWidth-8) + canNotTrim: false, + trimDuration: 3, + trimEnd: 3, + maxDuration: node.duration })); + 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]); //END videoRefCallback @@ -121,15 +129,17 @@ export default memo(function VideoQuickTrim({ },[]); const handleChangeTrimDuration = (selected: string) =>{ - setTrimState((curr)=>({ - ...curr, - trimDuration: trimOptions[selected], - trimEnd: trimStart+ trimOptions[selected], - })) - onSelect({ - trimStartSeconds: trimStart, - trimEndSeconds: trimStart+ trimOptions[selected], - }); + if(!canNotTrim){ + setTrimState((curr)=>({ + ...curr, + trimDuration: trimOptions[selected], + trimEnd: trimStart+ trimOptions[selected], + })) + onSelect({ + trimStartSeconds: trimStart, + trimEndSeconds: trimStart+ trimOptions[selected], + }); + } } const handlePlaypause = ()=>{ @@ -172,7 +182,8 @@ export default memo(function VideoQuickTrim({ {videoRef.current && canNotTrim &&
- Warning: Sorry Your Video is TOO Short +
+

Warning: Sorry Your Video is TOO Short

} {/* END of Video Wrapper */} diff --git a/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss b/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss index e588f8c5b6..9c30de85ca 100644 --- a/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss +++ b/packages/fakeyou.com/src/components/common/VideoQuickTrim/styles.scss @@ -42,10 +42,21 @@ $playbar-height: 2rem; display: flex; justify-content: center; align-items: center; - background-color: #e66462; - opacity: 70%; + + div{ + position: absolute; + height: 100%; + width: 100%; + top:0; + left:0; + background-color: #e66462; + opacity: 70%; + } p{ - opacity: 1; + position: absolute; + margin-top: 230px; + width: 100%; + top:0; } } .playbar{ diff --git a/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/defaultValues.tsx b/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/defaultValues.tsx index 21c6d139ea..89d7fcc434 100644 --- a/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/defaultValues.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/defaultValues.tsx @@ -8,9 +8,9 @@ const initialValues = { //video Settings width: 1024, height: 1024, - maxDuration: 3, + maxDuration: 0, trimStart: 0, - trimEnd: 3, + trimEnd: 0, //Presents workflowConfig: "weight_99tz2nzbp5x9v55gqn5ekj1sd", diff --git a/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/pageVSTApp.tsx b/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/pageVSTApp.tsx index c5a55a8060..61f8fb4cea 100644 --- a/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/pageVSTApp.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/video_styletransfer/components/pageVSTApp/pageVSTApp.tsx @@ -174,18 +174,19 @@ export default function PageVSTApp({ variant="primary" /> - {/*