From 11286fa274d0f8c721b7d507fc64660eed4807fe Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Jul 2021 15:36:12 -0400 Subject: Add states and components for video trimming. --- src/screens/profile/CaptionScreen.tsx | 44 +++-------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) (limited to 'src/screens') diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index c6cf767f..4b5ac0c5 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -15,7 +15,6 @@ import { } from 'react-native'; import {MentionInputControlled} from '../../components'; import {Button, normalize} from 'react-native-elements'; -import Video from 'react-native-video'; import {useDispatch, useSelector} from 'react-redux'; import FrontArrow from '../../assets/icons/front-arrow.svg'; import {SearchBackground} from '../../components'; @@ -43,8 +42,7 @@ import {RootState} from '../../store/rootReducer'; import {MomentTagType} from '../../types'; import {SCREEN_WIDTH, StatusBarHeight} from '../../utils'; import {mentionPartTypes} from '../../utils/comments'; -import {Trimmer, VideoPlayer} from 'react-native-video-processing'; - +import {TrimmerPlayer} from '../../utils/trimmer'; /** * Upload Screen to allow users to upload posts to Tagg */ @@ -198,11 +196,6 @@ const CaptionScreen: React.FC = ({route, navigation}) => { } }; - const [currentTime, setCurrentTime] = useState(0); - const [startTime, setStartTime] = useState(0); - // todo: update with vid times - const [endTime, setEndTime] = useState(60); - return ( {loading ? : } @@ -229,39 +222,7 @@ const CaptionScreen: React.FC = ({route, navigation}) => { {...{title: moment ? moment.moment_category : title ?? ''}} /> {isMediaAVideo ? ( - <> - (this.videoPlayerRef = ref)} - startTime={startTime} // seconds - endTime={endTime} // seconds - play={true} // default false - replay={true} // should player play video again if it's ended - //rotate={true} // use this prop to rotate video if it captured in landscape mode iOS only - source={mediaUri} - playerWidth={360} // iOS only - playerHeight={680} // iOS only - //resizeMode={VideoPlayer.Constants.resizeMode.CONTAIN} - onChange={({nativeEvent}) => - setCurrentTime(nativeEvent.currentTime) - } // get Current time on every second - /> - setCurrentTime(e.currentTime)} // iOS only - currentTime={currentTime} // use this prop to set tracker position iOS only - themeColor={'white'} // iOS only - showTrackerHandle={true} - thumbWidth={10} // iOS only - trackerColor={'green'} // iOS only - onChange={(e) => { - setStartTime(e.startTime); - setEndTime(e.endTime); - }} - /> - + ) : ( = ({route, navigation}) => { ); }; + const styles = StyleSheet.create({ contentContainer: { paddingTop: StatusBarHeight, -- cgit v1.2.3-70-g09d2 From e9678b4dc94f04c192ad5573bb2debc6e28f21b6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Jul 2021 16:22:26 -0400 Subject: Fix cropping bug. Updated the source to be the correct higher res video. --- src/components/moments/trimmer.tsx | 129 ++++++++++++++++++++++++++++++++++ src/screens/moments/CameraScreen.tsx | 4 +- src/screens/profile/CaptionScreen.tsx | 2 +- src/utils/trimmer.tsx | 106 ---------------------------- 4 files changed, 132 insertions(+), 109 deletions(-) create mode 100644 src/components/moments/trimmer.tsx delete mode 100644 src/utils/trimmer.tsx (limited to 'src/screens') diff --git a/src/components/moments/trimmer.tsx b/src/components/moments/trimmer.tsx new file mode 100644 index 00000000..ebf0d59e --- /dev/null +++ b/src/components/moments/trimmer.tsx @@ -0,0 +1,129 @@ +import React, {useEffect, useState} from 'react'; +import Video from 'react-native-video'; +import {Trimmer, ProcessingManager} from 'react-native-video-processing'; +import {useRef} from 'react'; + +export const TrimmerPlayer: React.FC<{source: string; styles: Object}> = ({ + source, + styles, +}) => { + const playerRef = useRef