Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Filters and Save Video #1306

Merged
merged 15 commits into from
Nov 21, 2018
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Add fullscreenOrientation option for iOS [#1215](https://github.com/react-native-community/react-native-video/pull/1215)
* Update to ExoPlayer 2.9.0 [#1285](https://github.com/react-native-community/react-native-video/pull/1285)
* Switch useTextureView to default to `true` [#1286](https://github.com/react-native-community/react-native-video/pull/1286)
* Video Filters and Save Video [#1306](https://github.com/react-native-community/react-native-video/pull/1306)

### Version 3.2.0
* Basic fullscreen support for Android MediaPlayer [#1138](https://github.com/react-native-community/react-native-video/pull/1138)
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ var styles = StyleSheet.create({
* [textTracks](#texttracks)
* [useTextureView](#usetextureview)
* [volume](#volume)
* [filter](#filter)

### Event props
* [onAudioBecomingNoisy](#onaudiobecomingnoisy)
Expand All @@ -299,6 +300,7 @@ var styles = StyleSheet.create({
* [dismissFullscreenPlayer](#dismissfullscreenplayer)
* [presentFullscreenPlayer](#presentfullscreenplayer)
* [seek](#seek)
* [saveAsync](#saveAsync())

### Configurable props

Expand Down Expand Up @@ -665,6 +667,17 @@ Adjust the volume.

Platforms: all

#### filter
Add video filter
* **Normal (default)** - Normal Filter
* **Country** - Sepia Filter
* **Winter** - Cool Filter
* **Black N White** - Black and White Filter
* **Sunrise** - Warm Filter
* **Artistic** - Posterize Filter

Platforms: iOS

### Event props

#### onAudioBecomingNoisy
Expand Down Expand Up @@ -902,6 +915,19 @@ this.player.seek(120, 50); // Seek to 2 minutes with +/- 50 milliseconds accurac

Platforms: iOS

##### saveAsync()
`saveAsync(): Promise`

Save video with current filter. Returns promise.

Example:
```
let response = await this.save();
let path = response.uri;
```

Platforms: iOS


### iOS App Transport Security

Expand Down
9 changes: 8 additions & 1 deletion Video.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform} from 'react-native';
import {StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform, findNodeHandle} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import TextTrackType from './TextTrackType';
import VideoResizeMode from './VideoResizeMode.js';
Expand Down Expand Up @@ -71,6 +71,10 @@ export default class Video extends Component {
this.setNativeProps({ fullscreen: false });
};

saveAsync = async (options?) => {
return await NativeModules.VideoManager.save(options, findNodeHandle(this._root));
}

_assignRoot = (component) => {
this._root = component;
};
Expand Down Expand Up @@ -274,7 +278,10 @@ export default class Video extends Component {
}
}

Video.filterTypes = ['Normal', 'Country', 'Winter', 'Black N White', 'Sunrise', 'Artistic'];

Video.propTypes = {
filter: PropTypes.oneOf(Video.filterTypes),
/* Native only */
src: PropTypes.object,
seek: PropTypes.oneOfType([
Expand Down
3 changes: 3 additions & 0 deletions ios/Video/RCTVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "RCTVideoPlayerViewController.h"
#import "RCTVideoPlayerViewControllerDelegate.h"
#import <React/RCTComponent.h>
#import <React/RCTBridgeModule.h>

#if __has_include(<react-native-video/RCTVideoCache.h>)
#import <react-native-video/RCTVideoCache.h>
Expand Down Expand Up @@ -41,4 +42,6 @@

- (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem;

- (void)save:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;

@end
Loading