diff --git a/README.md b/README.md index a3a67323..b7a87b53 100644 --- a/README.md +++ b/README.md @@ -913,15 +913,17 @@ let path = response.uri; Notes: - Currently only supports highest quality 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 + - 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: - Will support multiple qualities through options - Will support more formats in the future through options - Will support custom directory and file name through options - Platforms: iOS #### seek() diff --git a/examples/video-caching/App.ios.js b/examples/video-caching/App.ios.js index e214cfc1..20f69745 100644 --- a/examples/video-caching/App.ios.js +++ b/examples/video-caching/App.ios.js @@ -5,7 +5,7 @@ */ 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"; const { height, width } = Dimensions.get("screen"); @@ -28,6 +28,16 @@ export default class App extends Component { }} style={{ flex: 1, height, width }} /> + { + let response = await this.player.save(); + let uri = response.uri; + console.log("Download URI", uri); + }} + style={styles.button} + > + Save + ); } @@ -40,6 +50,14 @@ const styles = StyleSheet.create({ alignItems: "center", backgroundColor: "#F5FCFF" }, + button: { + position: 'absolute', + top: 50, + right: 16, + padding: 10, + backgroundColor: '#9B2FAE', + borderRadius: 8 + }, welcome: { fontSize: 20, textAlign: "center", diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index b5a26c3b..adf6cde9 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -1390,7 +1390,7 @@ static int const RCTVideoUnset = -1; if (exportSession != nil) { NSString *path = nil; NSArray *array = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - path = [self generatePathInDirectory:[[self cacheDirectoryPath] stringByAppendingPathComponent:@"Filter"] + path = [self generatePathInDirectory:[[self cacheDirectoryPath] stringByAppendingPathComponent:@"Videos"] withExtension:@".mp4"]; NSURL *url = [NSURL fileURLWithPath:path]; exportSession.outputFileType = AVFileTypeMPEG4;