Updated save function README, updated video-caching example to test saving function

This commit is contained in:
Nicolas Gonzalez 2018-11-06 20:33:33 -06:00
parent dd1c6867ad
commit 8a3b6490dc
3 changed files with 24 additions and 4 deletions

View File

@ -913,15 +913,17 @@ let path = response.uri;
Notes: Notes:
- Currently only supports highest quality export - Currently only supports highest quality export
- Currently only supports MP4 export - Currently only supports MP4 export
- Currently only supports exporting to user's cache directory with the file name "Filter.mp4" - Currently only supports exporting to user's cache directory with a generated UUID filename.
- User will need to remove the saved video through their Photos app - User will need to remove the saved video through their Photos app
- Works with cached videos as well. (Checkout video-caching example)
- If the video is has not began buffering (e.g. there is no internet connection) then the save function will throw an error.
- If the video is buffering then the save function promise will return after the video has finished buffering and processing.
Future: Future:
- Will support multiple qualities through options - Will support multiple qualities through options
- Will support more formats in the future through options - Will support more formats in the future through options
- Will support custom directory and file name through options - Will support custom directory and file name through options
Platforms: iOS Platforms: iOS
#### seek() #### seek()

View File

@ -5,7 +5,7 @@
*/ */
import React, { Component } from "react"; import React, { Component } from "react";
import { StyleSheet, Text, View, Dimensions } from "react-native"; import { StyleSheet, Text, View, Dimensions, TouchableOpacity } from "react-native";
import Video from "react-native-video"; import Video from "react-native-video";
const { height, width } = Dimensions.get("screen"); const { height, width } = Dimensions.get("screen");
@ -28,6 +28,16 @@ export default class App extends Component<Props> {
}} }}
style={{ flex: 1, height, width }} style={{ flex: 1, height, width }}
/> />
<TouchableOpacity
onPress={async () => {
let response = await this.player.save();
let uri = response.uri;
console.log("Download URI", uri);
}}
style={styles.button}
>
<Text style={{color: 'white'}}>Save</Text>
</TouchableOpacity>
</View> </View>
); );
} }
@ -40,6 +50,14 @@ const styles = StyleSheet.create({
alignItems: "center", alignItems: "center",
backgroundColor: "#F5FCFF" backgroundColor: "#F5FCFF"
}, },
button: {
position: 'absolute',
top: 50,
right: 16,
padding: 10,
backgroundColor: '#9B2FAE',
borderRadius: 8
},
welcome: { welcome: {
fontSize: 20, fontSize: 20,
textAlign: "center", textAlign: "center",

View File

@ -1390,7 +1390,7 @@ static int const RCTVideoUnset = -1;
if (exportSession != nil) { if (exportSession != nil) {
NSString *path = nil; NSString *path = nil;
NSArray *array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSArray *array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
path = [self generatePathInDirectory:[[self cacheDirectoryPath] stringByAppendingPathComponent:@"Filter"] path = [self generatePathInDirectory:[[self cacheDirectoryPath] stringByAppendingPathComponent:@"Videos"]
withExtension:@".mp4"]; withExtension:@".mp4"];
NSURL *url = [NSURL fileURLWithPath:path]; NSURL *url = [NSURL fileURLWithPath:path];
exportSession.outputFileType = AVFileTypeMPEG4; exportSession.outputFileType = AVFileTypeMPEG4;