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/utils/camera.ts | 13 +------ src/utils/trimmer.tsx | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 src/utils/trimmer.tsx (limited to 'src/utils') diff --git a/src/utils/camera.ts b/src/utils/camera.ts index ccdd42b0..f95499a5 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -8,10 +8,9 @@ import { TakePictureOptions, TakePictureResponse, } from 'react-native-camera'; -import {ProcessingManager} from 'react-native-video-processing'; + import ImagePicker, {ImageOrVideo, Video} from 'react-native-image-crop-picker'; import {ERROR_UPLOAD} from '../constants/strings'; -import RNFetchBlob from 'rn-fetch-blob'; /* * Captures a photo and pauses to show the preview of the picture taken @@ -69,9 +68,6 @@ export const navigateToImagePicker = ( mediaType: 'any', }) .then((media) => { - const path: String = getVideoPath(media); - ProcessingManager.compress(path, options.compress) // like VideoPlayer compress options - .then((data: any) => console.log(data)); callback(media); }) .catch((err) => { @@ -81,19 +77,12 @@ export const navigateToImagePicker = ( }); }; -const getVideoPath = (uri) => { - console.log(uri); - return uri.path; -}; - export const navigateToVideoPicker = (callback: (vid: Video) => void) => { ImagePicker.openPicker({ mediaType: 'video', }) .then(async (vid) => { if (vid.path) { - ProcessingManager.compress(vid.path, options.compress) // like VideoPlayer compress options - .then((data: any) => console.log(data)); callback(vid); } }) diff --git a/src/utils/trimmer.tsx b/src/utils/trimmer.tsx new file mode 100644 index 00000000..11d93ea8 --- /dev/null +++ b/src/utils/trimmer.tsx @@ -0,0 +1,106 @@ +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