react-native-video-processing 1.6.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/.travis.yml +1 -1
  2. package/CODE_OF_CONDUCT.md +46 -0
  3. package/ISSUE_TEMPLATE.md +21 -0
  4. package/README.md +97 -41
  5. package/_config.yml +1 -0
  6. package/android/build.gradle +26 -10
  7. package/android/react-native-video-processing.iml +8 -17
  8. package/android/src/main/java/com/shahenlibrary/Events/Events.java +2 -0
  9. package/android/src/main/java/com/shahenlibrary/RNVideoProcessingPackage.java +1 -2
  10. package/android/src/main/java/com/shahenlibrary/Trimmer/Trimmer.java +705 -112
  11. package/android/src/main/java/com/shahenlibrary/Trimmer/TrimmerManager.java +50 -7
  12. package/android/src/main/java/com/shahenlibrary/VideoPlayer/VideoPlayerView.java +80 -6
  13. package/android/src/main/java/com/shahenlibrary/VideoPlayer/VideoPlayerViewManager.java +35 -12
  14. package/android/src/main/java/com/shahenlibrary/interfaces/OnCompressVideoListener.java +8 -0
  15. package/android/src/main/java/com/shahenlibrary/utils/VideoEdit.java +34 -7
  16. package/android/src/main/jniLibs/arm64-v8a/libffmpeg.so +0 -0
  17. package/android/src/main/jniLibs/armeabi-v7a/libffmpeg.so +0 -0
  18. package/android/src/main/jniLibs/x86/libffmpeg.so +0 -0
  19. package/android/src/main/jniLibs/x86_64/libffmpeg.so +0 -0
  20. package/ios/RNVideoProcessing/RCTSwiftBridgeModule.h +29 -0
  21. package/ios/RNVideoProcessing/RNTrimmerView/ICGVideoTrimmer/ICGVideoTrimmerView.h +5 -0
  22. package/ios/RNVideoProcessing/RNTrimmerView/ICGVideoTrimmer/ICGVideoTrimmerView.m +48 -13
  23. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerView.h +1 -0
  24. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerView.swift +107 -36
  25. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerViewBridge.m +4 -1
  26. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerViewManager.swift +4 -1
  27. package/ios/RNVideoProcessing/RNVideoPlayer.swift +372 -291
  28. package/ios/RNVideoProcessing/RNVideoProcessingBridge.m +4 -1
  29. package/ios/RNVideoProcessing/RNVideoProcessingManager.swift +18 -4
  30. package/ios/RNVideoProcessing/RNVideoTrimmer/AVUtilities.swift +81 -0
  31. package/ios/RNVideoProcessing/RNVideoTrimmer/RNVideoTrimmer.swift +630 -207
  32. package/ios/RNVideoProcessing/RNVideoTrimmer/RNVideoTrimmerBridge.m +8 -3
  33. package/ios/RNVideoProcessing/RNVideoTrimmer/SDAVAssetExportSession.m +32 -32
  34. package/ios/RNVideoProcessing/VideoProcessingGPUFilters.swift +0 -1
  35. package/ios/RNVideoProcessing.xcodeproj/project.pbxproj +10 -3
  36. package/lib/ProcessingManager/ProcessingManager.android.js +81 -17
  37. package/lib/ProcessingManager/ProcessingManager.ios.js +72 -10
  38. package/lib/ProcessingManager/index.js +1 -1
  39. package/lib/ProcessingManager/test/ProcessingManager.test.js +24 -0
  40. package/lib/ProcessingManager/types.android.js +26 -0
  41. package/lib/ProcessingManager/types.ios.js +21 -3
  42. package/lib/Trimmer/Trimmer.android.js +4 -6
  43. package/lib/Trimmer/Trimmer.ios.js +15 -3
  44. package/lib/Trimmer/test/Trimmer.test.js +6 -3
  45. package/lib/Trimmer/test/__snapshots__/Trimmer.test.js.snap +4 -1
  46. package/lib/VideoPlayer/VideoPlayer.android.js +76 -8
  47. package/lib/VideoPlayer/VideoPlayer.ios.js +193 -171
  48. package/lib/VideoPlayer/test/__snapshots__/VideoPlayer.test.js.snap +4 -1
  49. package/lib/utils/index.js +1 -1
  50. package/lib/utils/test/trimmer.test.js +55 -0
  51. package/lib/utils/test/utils.test.js +1 -1
  52. package/lib/utils/trimmer.js +12 -0
  53. package/package.json +37 -26
  54. package/.npmignore +0 -60
  55. package/init/index.js +0 -7
  56. package/ios/GPUImage/.npmignore +0 -25
  57. package/yarn.lock +0 -6183
@@ -1,4 +1,5 @@
1
- import React, { PropTypes, Component } from 'react';
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import {
3
4
  View,
4
5
  Image,
@@ -106,9 +107,6 @@ export class Trimmer extends Component {
106
107
  if (!source.trim()) {
107
108
  throw new Error('source should be valid string');
108
109
  }
109
- if (!TrimmerManager) {
110
- throw new Error('RNTrimmerManager: Native Module installed not correctly');
111
- }
112
110
  this._retrivePreviewImages();
113
111
  this._retriveInfo();
114
112
  }
@@ -248,9 +246,9 @@ export class Trimmer extends Component {
248
246
  });
249
247
  }}
250
248
  >
251
- {images.map((uri) => (
249
+ {images.map((uri,index) => (
252
250
  <Image
253
- key={`preview-source-${uri}`}
251
+ key={`preview-source-${uri}-${index}`}
254
252
  source={{ uri }}
255
253
  style={styles.imageItem}
256
254
  />
@@ -1,4 +1,5 @@
1
- import React, { PropTypes, Component } from 'react';
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import { requireNativeComponent, processColor } from 'react-native';
3
4
  import { getActualSource } from '../utils';
4
5
  const TRIMMER_COMPONENT_NAME = 'RNTrimmerView';
@@ -8,6 +9,8 @@ export class Trimmer extends Component {
8
9
  source: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
9
10
  width: PropTypes.number,
10
11
  height: PropTypes.number,
12
+ showTrackerHandle: PropTypes.bool,
13
+ trackerHandleColor: PropTypes.string,
11
14
  themeColor: PropTypes.string,
12
15
  onChange: PropTypes.func,
13
16
  onTrackerMove: PropTypes.func,
@@ -15,12 +18,15 @@ export class Trimmer extends Component {
15
18
  maxLength: PropTypes.number,
16
19
  currentTime: PropTypes.number,
17
20
  trackerColor: PropTypes.string,
18
- thumbWidth: PropTypes.number
21
+ thumbWidth: PropTypes.number,
22
+ borderWidth: PropTypes.number,
19
23
  };
20
24
 
21
25
  static defaultProps = {
22
26
  themeColor: 'gray',
23
- trackerColor: 'black'
27
+ trackerColor: 'black',
28
+ trackerHandleColor: 'gray',
29
+ showTrackerHandle: false
24
30
  };
25
31
 
26
32
  constructor(...args) {
@@ -56,6 +62,9 @@ export class Trimmer extends Component {
56
62
  currentTime,
57
63
  trackerColor,
58
64
  thumbWidth,
65
+ borderWidth,
66
+ showTrackerHandle,
67
+ trackerHandleColor
59
68
  } = this.props;
60
69
  const actualSource = getActualSource(source);
61
70
  return (
@@ -66,12 +75,15 @@ export class Trimmer extends Component {
66
75
  currentTime={currentTime}
67
76
  themeColor={processColor(themeColor).toString()}
68
77
  trackerColor={processColor(trackerColor).toString()}
78
+ showTrackerHandle={showTrackerHandle}
79
+ trackerHandleColor={processColor(trackerHandleColor).toString()}
69
80
  onTrackerMove={this._handleTrackerMove}
70
81
  pointerEvents={'box-none'}
71
82
  onChange={this._onChange}
72
83
  minLength={minLength}
73
84
  maxLength={maxLength}
74
85
  thumbWidth={thumbWidth}
86
+ borderWidth={borderWidth}
75
87
  />
76
88
  );
77
89
  }
@@ -1,15 +1,18 @@
1
1
  /* global expect, jest */
2
- import React, { Component } from 'react';
2
+ import React from 'react';
3
3
  import renderer from 'react-test-renderer';
4
4
 
5
5
  jest.mock('../Trimmer', () => {
6
- class Trimmer extends Component {
6
+ const React = require('react');
7
+ const Component = React.Component;
8
+
9
+ class Trimmer extends Component {
7
10
  render() {
8
11
  return React.createElement('View', this.props, null);
9
12
  }
10
13
  }
11
14
 
12
- return Trimmer;
15
+ return Trimmer;
13
16
  });
14
17
 
15
18
  import Trimmer from '../Trimmer';
@@ -1,8 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
1
3
  exports[`[Trimmer] should be render correctly 1`] = `
2
4
  <View
3
5
  height={300}
4
6
  onChange={[Function]}
5
7
  source="someSourceGoeshere"
6
8
  themeColor="blue"
7
- width={300} />
9
+ width={300}
10
+ />
8
11
  `;
@@ -1,4 +1,5 @@
1
- import React, { Component, PropTypes } from 'react';
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
2
3
  import { noop } from 'lodash';
3
4
  import {
4
5
  AppRegistry,
@@ -8,15 +9,24 @@ import {
8
9
  requireNativeComponent,
9
10
  CameraRoll,
10
11
  UIManager,
11
- findNodeHandle
12
+ findNodeHandle,
13
+ ViewPropTypes
12
14
  } from 'react-native';
13
15
  import { getActualSource } from '../utils';
14
16
 
15
- const ProcessingUI = UIManager.RNVideoProcessing;
17
+ const ProcessingUI = UIManager.getViewManagerConfig('RNVideoProcessing');
16
18
 
17
19
  export class VideoPlayer extends Component {
20
+ static Constants = {
21
+ resizeMode: {
22
+ CONTAIN: ProcessingUI.Constants.ScaleAspectFit,
23
+ COVER: ProcessingUI.Constants.ScaleAspectFill,
24
+ STRETCH: ProcessingUI.Constants.ScaleToFill,
25
+ NONE: ProcessingUI.Constants.ScaleNone
26
+ }
27
+ };
18
28
  static propTypes = {
19
- ...View.propTypes,
29
+ ...ViewPropTypes,
20
30
  play: PropTypes.bool,
21
31
  replay: PropTypes.bool,
22
32
  volume: PropTypes.number,
@@ -25,10 +35,11 @@ export class VideoPlayer extends Component {
25
35
  endTime: PropTypes.number,
26
36
  startTime: PropTypes.number,
27
37
  progressEventDelay: PropTypes.number,
28
- source: PropTypes.string.isRequired
38
+ source: PropTypes.string.isRequired,
39
+ resizeMode: PropTypes.string
29
40
  };
30
41
  static defaultProps = {
31
- onChange: noop
42
+ onChange: noop,
32
43
  };
33
44
 
34
45
  constructor(props) {
@@ -36,11 +47,14 @@ export class VideoPlayer extends Component {
36
47
  this._receiveVideoInfo = this._receiveVideoInfo.bind(this);
37
48
  this._receivePreviewImage = this._receivePreviewImage.bind(this);
38
49
  this._receiveTrimmedSource = this._receiveTrimmedSource.bind(this);
50
+ this._receiveCompressedSource = this._receiveCompressedSource.bind(this);
39
51
  this._onVideoProgress = this._onVideoProgress.bind(this);
40
52
  this.trim = this.trim.bind(this);
53
+ this.compress = this.compress.bind(this);
41
54
  this.getInfoPromisesResolves = [];
42
55
  this.getPreviewForSecondResolves = [];
43
56
  this.trimResolves = [];
57
+ this.compressResolves = [];
44
58
  }
45
59
 
46
60
  getVideoInfo() {
@@ -74,8 +88,43 @@ export class VideoPlayer extends Component {
74
88
  });
75
89
  }
76
90
 
77
- compress() {
78
- return Promise.resolve(this.props.source);
91
+ compress(_options = {}) {
92
+ const options = { ..._options };
93
+ // const options = {
94
+ // height: 1080, // output video's height
95
+ // width: 720, // output video's width
96
+ // bitrateMultiplier: 10, // divide video's bitrate to this value
97
+ // minimumBitrate: 250000,
98
+ // removeAudio: true, //default is false
99
+ // };
100
+ if (options.hasOwnProperty('bitrateMultiplier') && options.bitrateMultiplier <= 0) {
101
+ options.bitrateMultiplier = 1;
102
+ // eslint-disable-next-line no-console
103
+ console.warn('bitrateMultiplier cannot be less than zero');
104
+ }
105
+ if (options.hasOwnProperty('height') && options.height <= 0) {
106
+ delete options.height;
107
+ // eslint-disable-next-line no-console
108
+ console.warn('height cannot be less than zero');
109
+ }
110
+ if (options.hasOwnProperty('width') && options.width <= 0) {
111
+ delete options.width;
112
+ // eslint-disable-next-line no-console
113
+ console.warn('width cannot be less than zero');
114
+ }
115
+ if (options.hasOwnProperty('minimumBitrate') && options.minimumBitrate <= 0) {
116
+ delete options.minimumBitrate;
117
+ // eslint-disable-next-line no-console
118
+ console.warn('minimumBitrate cannot be less than zero');
119
+ }
120
+ UIManager.dispatchViewManagerCommand(
121
+ findNodeHandle(this),
122
+ ProcessingUI.Commands.compress,
123
+ [options]
124
+ );
125
+ return new Promise((resolve) => {
126
+ this.compressResolves.push(resolve);
127
+ });
79
128
  }
80
129
 
81
130
  getPreviewForSecond(forSecond = 0) {
@@ -94,6 +143,11 @@ export class VideoPlayer extends Component {
94
143
  this.trimResolves = [];
95
144
  }
96
145
 
146
+ _receiveCompressedSource(e) {
147
+ this.compressResolves.forEach((resolve) => resolve(e.nativeEvent.source));
148
+ this.compressResolves = [];
149
+ }
150
+
97
151
  _receiveVideoInfo({ nativeEvent }) {
98
152
  const event = {
99
153
  size: { width: nativeEvent.width, height: nativeEvent.height },
@@ -124,9 +178,21 @@ export class VideoPlayer extends Component {
124
178
  replay,
125
179
  volume,
126
180
  style,
181
+ resizeMode,
127
182
  ...props
128
183
  } = this.props;
129
184
  const mSource = getActualSource(source);
185
+
186
+ if (__DEV__) {
187
+ const isCompatible = Object
188
+ .values(VideoPlayer.Constants.resizeMode)
189
+ .includes(resizeMode);
190
+
191
+ if (!isCompatible) {
192
+ console.warn('Wrong resizeMode property, please use VideoPlayer.Constants.resizeMode constants');
193
+ }
194
+ }
195
+
130
196
  return (
131
197
  <RNVideoPlayer
132
198
  style={style}
@@ -136,10 +202,12 @@ export class VideoPlayer extends Component {
136
202
  getVideoInfo={this._receiveVideoInfo}
137
203
  getPreviewImage={this._receivePreviewImage}
138
204
  getTrimmedSource={this._receiveTrimmedSource}
205
+ getCompressedSource={this._receiveCompressedSource}
139
206
  currentTime={currentTime}
140
207
  endTime={endTime}
141
208
  startTime={startTime}
142
209
  replay={replay}
210
+ resizeMode={resizeMode}
143
211
  volume={volume}
144
212
  {...props}
145
213
  />
@@ -1,190 +1,212 @@
1
- import React, { PropTypes, Component } from 'react';
2
- import { View, requireNativeComponent, NativeModules } from 'react-native';
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { View, ViewPropTypes, requireNativeComponent, NativeModules, UIManager } from 'react-native';
3
4
  import { getActualSource } from '../utils';
4
5
  const PLAYER_COMPONENT_NAME = 'RNVideoProcessing';
5
6
 
6
7
  const { RNVideoTrimmer } = NativeModules;
7
8
 
9
+ const ProcessingUI = UIManager.getViewManagerConfig('RNVideoProcessing');
10
+
8
11
  export class VideoPlayer extends Component {
9
- static propTypes = {
10
- source: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
11
- play: PropTypes.bool,
12
- replay: PropTypes.bool,
13
- rotate: PropTypes.bool,
14
- currentTime: PropTypes.number,
15
- volume: PropTypes.number,
16
- startTime: PropTypes.number,
17
- background_Color: PropTypes.string,
18
- endTime: PropTypes.number,
19
- playerWidth: PropTypes.number,
20
- playerHeight: PropTypes.number,
21
- onChange: PropTypes.func,
22
- ...View.propTypes
23
- };
12
+ static propTypes = {
13
+ source: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
14
+ play: PropTypes.bool,
15
+ replay: PropTypes.bool,
16
+ rotate: PropTypes.bool,
17
+ currentTime: PropTypes.number,
18
+ volume: PropTypes.number,
19
+ startTime: PropTypes.number,
20
+ background_Color: PropTypes.string,
21
+ endTime: PropTypes.number,
22
+ playerWidth: PropTypes.number,
23
+ playerHeight: PropTypes.number,
24
+ onChange: PropTypes.func,
25
+ resizeMode: PropTypes.string,
26
+ ...ViewPropTypes
27
+ };
28
+
29
+ static defaultProps = {
30
+ play: false,
31
+ replay: false,
32
+ rotate: false,
33
+ resizeMode: ProcessingUI.Constants.ScaleNone,
34
+ volume: 0.0,
35
+ currentTime: 0,
36
+ startTime: 0,
37
+ };
24
38
 
25
- static defaultProps = {
26
- play: false,
27
- replay: false,
28
- rotate: false,
29
- volume: 0.0,
30
- currentTime: 0,
31
- startTime: 0,
32
- };
39
+ static Constants = {
40
+ quality: {
41
+ QUALITY_LOW: 'low',
42
+ QUALITY_MEDIUM: 'medium',
43
+ QUALITY_HIGHEST: 'highest',
44
+ QUALITY_640x480: '640x480',
45
+ QUALITY_960x540: '960x540',
46
+ QUALITY_1280x720: '1280x720',
47
+ QUALITY_1920x1080: '1920x1080',
48
+ QUALITY_3840x2160: '3840x2160', // available in iOS 9
49
+ QUALITY_PASS_THROUGH: 'passthrough', // does not change quality
50
+ },
51
+ resizeMode: {
52
+ CONTAIN: ProcessingUI.Constants.ScaleAspectFit,
53
+ COVER: ProcessingUI.Constants.ScaleAspectFill,
54
+ STRETCH: ProcessingUI.Constants.ScaleToFill,
55
+ NONE: ProcessingUI.Constants.ScaleNone
56
+ }
57
+ };
33
58
 
34
- static Constants = {
35
- quality: {
36
- QUALITY_LOW: 'low',
37
- QUALITY_MEDIUM: 'medium',
38
- QUALITY_HIGHEST: 'highest',
39
- QUALITY_640x480: '640x480',
40
- QUALITY_960x540: '960x540',
41
- QUALITY_1280x720: '1280x720',
42
- QUALITY_1920x1080: '1920x1080',
43
- QUALITY_3840x2160: '3840x2160', // available in iOS 9
44
- QUALITY_PASS_THROUGH: 'passthrough', // does not change quality
45
- }
46
- };
59
+ constructor(...args) {
60
+ super(...args);
61
+ this.state = {};
62
+ this.trim = this.trim.bind(this);
63
+ this.compress = this.compress.bind(this);
64
+ this.getPreviewForSecond = this.getPreviewForSecond.bind(this);
65
+ this.getVideoInfo = this.getVideoInfo.bind(this);
66
+ this._onChange = this._onChange.bind(this);
67
+ }
47
68
 
48
- constructor(...args) {
49
- super(...args);
50
- this.state = {};
51
- this.trim = this.trim.bind(this);
52
- this.compress = this.compress.bind(this);
53
- this.getPreviewForSecond = this.getPreviewForSecond.bind(this);
54
- this.getVideoInfo = this.getVideoInfo.bind(this);
55
- this._onChange = this._onChange.bind(this);
56
- }
69
+ getPreviewForSecond(forSecond = 0, maximumSize, format = 'base64') {
70
+ const actualSource = getActualSource(this.props.source);
71
+ return new Promise((resolve, reject) => {
72
+ RNVideoTrimmer.getPreviewImageAtPosition(actualSource, forSecond, maximumSize, format,
73
+ (err, base64) => {
74
+ if (err) {
75
+ return reject(err);
76
+ }
77
+ return resolve(base64);
78
+ });
79
+ });
80
+ }
57
81
 
58
- getPreviewForSecond(forSecond = 0, maximumSize) {
59
- const actualSource = getActualSource(this.props.source);
60
- return new Promise((resolve, reject) => {
61
- RNVideoTrimmer.getPreviewImageAtPosition(actualSource, forSecond, maximumSize,
62
- (err, base64) => {
63
- if (err) {
64
- return reject(err);
65
- }
66
- return resolve(base64);
67
- });
68
- });
69
- }
82
+ getVideoInfo() {
83
+ const actualSource = getActualSource(this.props.source);
84
+ return new Promise((resolve, reject) => {
85
+ RNVideoTrimmer.getAssetInfo(actualSource, (err, info) => {
86
+ if (err) {
87
+ return reject(err);
88
+ }
89
+ return resolve(info);
90
+ });
91
+ });
92
+ }
70
93
 
71
- getVideoInfo() {
72
- const actualSource = getActualSource(this.props.source);
73
- return new Promise((resolve, reject) => {
74
- RNVideoTrimmer.getAssetInfo(actualSource, (err, info) => {
75
- if (err) {
76
- return reject(err);
77
- }
78
- return resolve(info);
79
- });
80
- });
81
- }
94
+ _onChange(event) {
95
+ if (!this.props.onChange) {
96
+ return;
97
+ }
98
+ this.props.onChange(event);
99
+ }
82
100
 
83
- _onChange(event) {
84
- if (!this.props.onChange) {
85
- return;
86
- }
87
- this.props.onChange(event);
88
- }
101
+ trim(options = {}) {
102
+ const availableQualities = Object.values(VideoPlayer.Constants.quality);
103
+ if (!options.hasOwnProperty('startTime')) {
104
+ // eslint-disable-next-line no-console
105
+ console.warn('Start time is not specified');
106
+ }
107
+ if (!options.hasOwnProperty('endTime')) {
108
+ // eslint-disable-next-line no-console
109
+ console.warn('End time is not specified');
110
+ }
111
+ if (options.hasOwnProperty('quality') && !availableQualities.includes(options.quality)) {
112
+ // eslint-disable-next-line no-console
113
+ console.warn('Quality is wrong, Please use VideoPlayer.Constants.quality');
114
+ }
115
+ const actualSource = getActualSource(this.props.source);
116
+ return new Promise((resolve, reject) => {
117
+ RNVideoTrimmer.trim(actualSource, options, (err, output) => {
118
+ if (err) {
119
+ return reject(err);
120
+ }
121
+ return resolve(output);
122
+ });
123
+ });
124
+ }
89
125
 
90
- trim(options = {}) {
91
- const availableQualities = Object.values(VideoPlayer.Constants.quality);
92
- if (!options.hasOwnProperty('startTime')) {
93
- // eslint-disable-next-line no-console
94
- console.warn('Start time is not specified');
95
- }
96
- if (!options.hasOwnProperty('endTime')) {
97
- // eslint-disable-next-line no-console
98
- console.warn('End time is not specified');
99
- }
100
- if (options.hasOwnProperty('quality') && !availableQualities.includes(options.quality)) {
101
- // eslint-disable-next-line no-console
102
- console.warn('Quality is wrong, Please use VideoPlayer.Constants.quality');
103
- }
104
- const actualSource = getActualSource(this.props.source);
105
- return new Promise((resolve, reject) => {
106
- RNVideoTrimmer.trim(actualSource, options, (err, output) => {
107
- if (err) {
108
- return reject(err);
109
- }
110
- return resolve(output);
111
- });
112
- });
113
- }
126
+ compress(_options = {}) {
127
+ const options = { ..._options };
128
+ // const options = {
129
+ // height: 1080, // output video's height
130
+ // width: 720, // output video's width
131
+ // bitrateMultiplier: 10 // divide video's bitrate to this value
132
+ // };
133
+ if (options.hasOwnProperty('bitrateMultiplier') && options.bitrateMultiplier <= 0) {
134
+ options.bitrateMultiplier = 1;
135
+ // eslint-disable-next-line no-console
136
+ console.warn('bitrateMultiplier cannot be less than zero');
137
+ }
138
+ if (options.hasOwnProperty('height') && options.height <= 0) {
139
+ delete options.height;
140
+ // eslint-disable-next-line no-console
141
+ console.warn('height cannot be less than zero');
142
+ }
143
+ if (options.hasOwnProperty('width') && options.width <= 0) {
144
+ delete options.width;
145
+ // eslint-disable-next-line no-console
146
+ console.warn('width cannot be less than zero');
147
+ }
148
+ if (options.hasOwnProperty('minimumBitrate') && options.minimumBitrate <= 0) {
149
+ delete options.minimumBitrate;
150
+ // eslint-disable-next-line no-console
151
+ console.warn('minimumBitrate cannot be less than zero');
152
+ }
153
+ const actualSource = getActualSource(this.props.source);
154
+ return new Promise((resolve, reject) => {
155
+ RNVideoTrimmer.compress(actualSource, options, (err, output) => {
156
+ if (err) {
157
+ return reject(err);
158
+ }
159
+ return resolve(output);
160
+ });
161
+ });
162
+ }
114
163
 
115
- compress(_options = {}) {
116
- const options = { ..._options };
117
- // const options = {
118
- // height: 1080, // output video's height
119
- // width: 720, // output video's width
120
- // bitrateMultiplier: 10 // divide video's bitrate to this value
121
- // };
122
- if (options.hasOwnProperty('bitrateMultiplier') && options.bitrateMultiplier <= 0) {
123
- options.bitrateMultiplier = 1;
124
- // eslint-disable-next-line no-console
125
- console.warn('bitrateMultiplier cannot be less than zero');
126
- }
127
- if (options.hasOwnProperty('height') && options.height <= 0) {
128
- delete options.height;
129
- // eslint-disable-next-line no-console
130
- console.warn('height cannot be less than zero');
131
- }
132
- if (options.hasOwnProperty('width') && options.width <= 0) {
133
- delete options.width;
134
- // eslint-disable-next-line no-console
135
- console.warn('width cannot be less than zero');
136
- }
137
- if (options.hasOwnProperty('minimumBitrate') && options.minimumBitrate <= 0) {
138
- delete options.minimumBitrate;
139
- // eslint-disable-next-line no-console
140
- console.warn('minimumBitrate cannot be less than zero');
141
- }
142
- const actualSource = getActualSource(this.props.source);
143
- return new Promise((resolve, reject) => {
144
- RNVideoTrimmer.compress(actualSource, options, (err, output) => {
145
- if (err) {
146
- return reject(err);
147
- }
148
- return resolve(output);
149
- });
150
- });
151
- }
164
+ render() {
165
+ const {
166
+ source,
167
+ play,
168
+ replay,
169
+ rotate,
170
+ currentTime,
171
+ backgroundColor,
172
+ startTime,
173
+ endTime,
174
+ playerWidth,
175
+ playerHeight,
176
+ volume,
177
+ resizeMode,
178
+ ...viewProps
179
+ } = this.props;
152
180
 
153
- render() {
154
- const {
155
- source,
156
- play,
157
- replay,
158
- rotate,
159
- currentTime,
160
- backgroundColor,
161
- startTime,
162
- endTime,
163
- playerWidth,
164
- playerHeight,
165
- volume,
166
- ...viewProps
167
- } = this.props;
181
+ if (__DEV__) {
182
+ const isCompatible = Object
183
+ .values(VideoPlayer.Constants.resizeMode)
184
+ .includes(resizeMode);
185
+ if (!isCompatible) {
186
+ console.warn('Wrong resizeMode property, please use VideoPlayer.Constants.resizeMode constants');
187
+ }
188
+ }
168
189
 
169
- const actualSource = getActualSource(source);
170
- return (
171
- <RNVideoPlayer
172
- source={actualSource}
173
- play={play}
174
- replay={replay}
175
- rotate={rotate}
176
- volume={volume}
177
- playerWidth={playerWidth}
178
- playerHeight={playerHeight}
179
- currentTime={currentTime}
180
- background_Color={backgroundColor}
181
- startTime={startTime}
182
- endTime={endTime}
183
- onChange={this._onChange}
184
- {...viewProps}
185
- />
186
- );
187
- }
190
+ const actualSource = getActualSource(source);
191
+ return (
192
+ <RNVideoPlayer
193
+ source={actualSource}
194
+ play={play}
195
+ replay={replay}
196
+ rotate={rotate}
197
+ volume={volume}
198
+ playerWidth={playerWidth}
199
+ playerHeight={playerHeight}
200
+ currentTime={currentTime}
201
+ background_Color={backgroundColor}
202
+ startTime={startTime}
203
+ endTime={endTime}
204
+ onChange={this._onChange}
205
+ resizeMode={resizeMode}
206
+ {...viewProps}
207
+ />
208
+ );
209
+ }
188
210
  }
189
211
 
190
212
  const RNVideoPlayer = requireNativeComponent(PLAYER_COMPONENT_NAME, VideoPlayer);
@@ -1,4 +1,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
1
3
  exports[`VideoPlayer Should render correctly 1`] = `
2
4
  <VideoPlayer
3
- source="somePath" />
5
+ source="somePath"
6
+ />
4
7
  `;
@@ -1,2 +1,2 @@
1
1
  export { getActualSource } from './utils';
2
- export { calculateCornerResult, msToSec } from './trimmer';
2
+ export { calculateCornerResult, msToSec, numberToHHMMSS } from './trimmer';