From b6afaa3378fed72d6bd356f9a76dce965e350cf7 Mon Sep 17 00:00:00 2001 From: Nicolas Ngomai Date: Thu, 11 May 2017 13:46:04 +0200 Subject: [PATCH 01/40] Add link to propTypes Some props are missing in the documentation, the propTypes provides a full list of those. I think it would help a lot of developers to add a link here. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e473a766..11819fb2 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,8 @@ var styles = StyleSheet.create({ - * *For iOS you also need to specify muted for this to work* +To see full list of available props, you can check [the propTypes](https://github.com/react-native-community/react-native-video/blob/master/Video.js#L246) of the Video.js component. + ## Android Expansion File Usage ```javascript From 451f8d0919e94e44d7b294b187ac527533d06b82 Mon Sep 17 00:00:00 2001 From: Alex Fox Date: Thu, 7 Sep 2017 13:16:44 +0100 Subject: [PATCH 02/40] Fixed rate not being respected after seeking Referenced in issue => https://github.com/react-native-community/react-native-video/issues/763 --- ios/RCTVideo.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 9962c2bb..097e16c8 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -561,7 +561,9 @@ static NSString *const timedMetadata = @"timedMetadata"; if (CMTimeCompare(current, cmSeekTime) != 0) { if (!wasPaused) [_player pause]; [_player seekToTime:cmSeekTime toleranceBefore:tolerance toleranceAfter:tolerance completionHandler:^(BOOL finished) { - if (!wasPaused) [_player play]; + if (!wasPaused) { + [self setPaused:false]; + } if(self.onVideoSeek) { self.onVideoSeek(@{@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(item.currentTime)], @"seekTime": [NSNumber numberWithFloat:seekTime], From 1bdd8720fbc08b2a04edf2b59e8e03063ed41c48 Mon Sep 17 00:00:00 2001 From: Anne Glines Date: Mon, 11 Sep 2017 22:30:17 -0700 Subject: [PATCH 03/40] Reseting isCompleted flag on source change --- android/src/main/java/com/brentvatne/react/ReactVideoView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 94a25a0e..f426c30e 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -297,6 +297,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP WritableMap event = Arguments.createMap(); event.putMap(ReactVideoViewManager.PROP_SRC, src); mEventEmitter.receiveEvent(getId(), Events.EVENT_LOAD_START.toString(), event); + isCompleted = false; try { prepareAsync(this); From 3e0f084c621e7af0a60a13c701cb94cd3b211041 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik Date: Wed, 27 Sep 2017 16:13:29 +0100 Subject: [PATCH 04/40] Implement 'rate' prop for android devices - Version locked to 6.0+ because that is the version that introduced setPlaybackParams - Ignores rate prop as before on android versions lower than 6.0 --- .../main/java/com/brentvatne/react/ReactVideoView.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 94a25a0e..099bec33 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -5,6 +5,7 @@ import android.content.res.AssetFileDescriptor; import android.graphics.Matrix; import android.media.MediaPlayer; import android.net.Uri; +import android.os.Build; import android.os.Handler; import android.util.Log; import android.view.MotionEvent; @@ -377,8 +378,11 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP mRate = rate; if (mMediaPlayerValid) { - // TODO: Implement this. - Log.e(ReactVideoViewManager.REACT_CLASS, "Setting playback rate is not yet supported on Android"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + mMediaPlayer.setPlaybackParams(mMediaPlayer.getPlaybackParams().setSpeed(rate)); + } else { + Log.e(ReactVideoViewManager.REACT_CLASS, "Setting playback rate is not yet supported on Android versions below 6.0"); + } } } @@ -388,7 +392,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP setPausedModifier(mPaused); setMutedModifier(mMuted); setProgressUpdateInterval(mProgressUpdateInterval); -// setRateModifier(mRate); + setRateModifier(mRate); } public void setPlayInBackground(final boolean playInBackground) { From 1ba6b062e4ac7a415e4d3602f15965f7bf93c779 Mon Sep 17 00:00:00 2001 From: thomasobrien99 Date: Fri, 3 Nov 2017 11:38:37 -0700 Subject: [PATCH 05/40] View.propTypes -> ViewPropTypes (#824) --- Video.js | 4 ++-- ViewPropTypes | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 ViewPropTypes diff --git a/Video.js b/Video.js index b90c030e..feb79861 100644 --- a/Video.js +++ b/Video.js @@ -1,6 +1,6 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; -import {StyleSheet, requireNativeComponent, NativeModules, View, Image} from 'react-native'; +import {StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image} from 'react-native'; import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'; import VideoResizeMode from './VideoResizeMode.js'; @@ -308,7 +308,7 @@ Video.propTypes = { translateX: PropTypes.number, translateY: PropTypes.number, rotation: PropTypes.number, - ...View.propTypes, + ...ViewPropTypes, }; const RCTVideo = requireNativeComponent('RCTVideo', Video, { diff --git a/ViewPropTypes b/ViewPropTypes new file mode 100644 index 00000000..0641bc0d --- /dev/null +++ b/ViewPropTypes @@ -0,0 +1 @@ +M Video.js From 6e43701092f5f480eab8ae005a4bc729bb21b5c1 Mon Sep 17 00:00:00 2001 From: Ahmed Hassan Date: Sat, 18 Nov 2017 23:10:58 +0100 Subject: [PATCH 06/40] added native progress notification (#734) --- ios/RCTVideo.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 9962c2bb..58eaf608 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -188,6 +188,9 @@ static NSString *const timedMetadata = @"timedMetadata"; CMTime currentTime = _player.currentTime; const Float64 duration = CMTimeGetSeconds(playerDuration); const Float64 currentTimeSecs = CMTimeGetSeconds(currentTime); + + [[NSNotificationCenter defaultCenter] postNotificationName:@"RCTVideo_progress" object:nil userInfo:@{@"progress": [NSNumber numberWithDouble: currentTimeSecs / duration]}]; + if( currentTimeSecs >= 0 && self.onVideoProgress) { self.onVideoProgress(@{ @"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(currentTime)], From c0a8f7c0c9ebf1a82a6f37381de9d96754c931c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay=20Pl=C3=B6=C3=9Fer?= Date: Fri, 24 Nov 2017 16:22:41 +0100 Subject: [PATCH 07/40] Document fullscreen callbacks fix #861 --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 597b71ec..01470edf 100644 --- a/README.md +++ b/README.md @@ -165,12 +165,16 @@ using System.Collections.Generic; playWhenInactive={false} // [iOS] Video continues to play when control or notification center are shown. ignoreSilentSwitch={"ignore"} // [iOS] ignore | obey - When 'ignore', audio will still play with the iOS hard silent switch set to silent. When 'obey', audio will toggle with the switch. When not specified, will inherit audio settings as usual. progressUpdateInterval={250.0} // [iOS] Interval to fire onProgress (default to ~250ms) + onBuffer={this.onBuffer} // Callback when remote video is buffering + onEnd={this.onEnd} // Callback when playback finishes + onError={this.videoError} // Callback when video cannot be loaded + onFullscreenPlayerWillPresent={this.fullScreenPlayerWillPresent} // Callback before fullscreen starts + onFullscreenPlayerDidPresent={this.fullScreenPlayerDidPresent} // Callback after fullscreen started + onFullscreenPlayerWillDismiss={this.fullScreenPlayerWillDismiss} // Callback before fullscreen stops + onFullscreenPlayerDidDismiss={this.fullScreenPlayerDidDissmiss} // Callback after fullscreen stopped onLoadStart={this.loadStart} // Callback when video starts to load onLoad={this.setDuration} // Callback when video loads onProgress={this.setTime} // Callback every ~250ms with currentTime - onEnd={this.onEnd} // Callback when playback finishes - onError={this.videoError} // Callback when video cannot be loaded - onBuffer={this.onBuffer} // Callback when remote video is buffering onTimedMetadata={this.onTimedMetadata} // Callback when the stream receive some metadata style={styles.backgroundVideo} /> From ebe138fa8dad21a4fd786b41a1e541d44c511c9b Mon Sep 17 00:00:00 2001 From: vengadesh Date: Wed, 6 Dec 2017 08:56:41 -0800 Subject: [PATCH 08/40] Raising error for source exception (#799) --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 7 ++++++- android-exoplayer/src/main/res/values/strings.xml | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 52bf24e6..f24d94c2 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -482,6 +482,7 @@ class ReactExoplayerView extends FrameLayout implements @Override public void onPlayerError(ExoPlaybackException e) { String errorString = null; + Exception ex = e; if (e.type == ExoPlaybackException.TYPE_RENDERER) { Exception cause = e.getRendererException(); if (cause instanceof MediaCodecRenderer.DecoderInitializationException) { @@ -504,8 +505,12 @@ class ReactExoplayerView extends FrameLayout implements } } } + else if (e.type == ExoPlaybackException.TYPE_SOURCE) { + ex = e.getSourceException(); + errorString = getResources().getString(R.string.unrecognized_media_format); + } if (errorString != null) { - eventEmitter.error(errorString, e); + eventEmitter.error(errorString, ex); } playerNeedsSource = true; if (isBehindLiveWindow(e)) { diff --git a/android-exoplayer/src/main/res/values/strings.xml b/android-exoplayer/src/main/res/values/strings.xml index b92a238a..4f69ec34 100644 --- a/android-exoplayer/src/main/res/values/strings.xml +++ b/android-exoplayer/src/main/res/values/strings.xml @@ -9,4 +9,6 @@ Unable to instantiate decoder %1$s + Unrecognized media format + From ce7c732453476cf77b8583981601f521cbb83410 Mon Sep 17 00:00:00 2001 From: Jordan Becker Date: Thu, 7 Dec 2017 19:35:32 +0100 Subject: [PATCH 09/40] Add requiresMainQueueSetup method Since RN 0.49, `requiresMainQueueSetup` needs to be defined if the module overrides `constantsToExport`. --- ios/RCTVideoManager.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ios/RCTVideoManager.m b/ios/RCTVideoManager.m index a5cf85e0..c1edb9b7 100644 --- a/ios/RCTVideoManager.m +++ b/ios/RCTVideoManager.m @@ -62,4 +62,9 @@ RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTBubblingEventBlock); }; } ++ (BOOL)requiresMainQueueSetup +{ + return YES; +} + @end From 64191298e514ab52b9cb4fcabcb7e38b40a698fe Mon Sep 17 00:00:00 2001 From: sm2017 Date: Sun, 24 Dec 2017 14:44:00 +0330 Subject: [PATCH 10/40] Update ReactVideoView.cs Fix 'Event' does not contain a constructor that takes 2 arguments ReactNativeVideo --- windows/ReactNativeVideo.Net46/ReactVideoView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/ReactNativeVideo.Net46/ReactVideoView.cs b/windows/ReactNativeVideo.Net46/ReactVideoView.cs index 8a8b1b29..643965ee 100644 --- a/windows/ReactNativeVideo.Net46/ReactVideoView.cs +++ b/windows/ReactNativeVideo.Net46/ReactVideoView.cs @@ -328,7 +328,7 @@ namespace ReactNativeVideo private readonly JObject _eventData; public ReactVideoEvent(string eventName, int viewTag, JObject eventData) - : base(viewTag, TimeSpan.FromTicks(Environment.TickCount)) + : base(viewTag) { _eventName = eventName; _eventData = eventData; From dd242476a3615055343c0c06a119713f9df6fb0e Mon Sep 17 00:00:00 2001 From: sm2017 Date: Sun, 24 Dec 2017 14:46:02 +0330 Subject: [PATCH 11/40] Update ReactVideoView.cs Fix 'Event' does not contain a constructor that takes 2 arguments ReactNativeVideo --- windows/ReactNativeVideo/ReactVideoView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/ReactNativeVideo/ReactVideoView.cs b/windows/ReactNativeVideo/ReactVideoView.cs index 22063aff..5a6c103f 100644 --- a/windows/ReactNativeVideo/ReactVideoView.cs +++ b/windows/ReactNativeVideo/ReactVideoView.cs @@ -334,7 +334,7 @@ namespace ReactNativeVideo private readonly JObject _eventData; public ReactVideoEvent(string eventName, int viewTag, JObject eventData) - : base(viewTag, TimeSpan.FromTicks(Environment.TickCount)) + : base(viewTag) { _eventName = eventName; _eventData = eventData; From 093ffccd9b99f5b1de10832f01cda895bcb64a3a Mon Sep 17 00:00:00 2001 From: Austin Witherow Date: Tue, 2 Jan 2018 12:06:43 -0500 Subject: [PATCH 12/40] fix(ios): crash due to persistent keyPath observer (#600) --- ios/RCTVideo.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 58eaf608..0f1227b1 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -252,6 +252,9 @@ static NSString *const timedMetadata = @"timedMetadata"; * observer set */ - (void)removePlayerItemObservers { + if (_playerLayer) { + [_playerLayer removeObserver:self forKeyPath:readyForDisplayKeyPath]; + } if (_playerItemObserversSet) { [_playerItem removeObserver:self forKeyPath:statusKeyPath]; [_playerItem removeObserver:self forKeyPath:playbackBufferEmptyKeyPath]; From 7d48f22d9871bf98f4a1208e53d218954135f6fa Mon Sep 17 00:00:00 2001 From: Alejandro Rangel Date: Thu, 11 Jan 2018 09:16:29 -0800 Subject: [PATCH 13/40] add seekableDuration to android ReactVideoView --- android/src/main/java/com/brentvatne/react/ReactVideoView.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 94a25a0e..f609bcc4 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -64,6 +64,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP public static final String EVENT_PROP_DURATION = "duration"; public static final String EVENT_PROP_PLAYABLE_DURATION = "playableDuration"; + public static final String EVENT_PROP_SEEKABLE_DURATION = "seekableDuration"; public static final String EVENT_PROP_CURRENT_TIME = "currentTime"; public static final String EVENT_PROP_SEEK_TIME = "seekTime"; public static final String EVENT_PROP_NATURALSIZE = "naturalSize"; @@ -127,6 +128,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP WritableMap event = Arguments.createMap(); event.putDouble(EVENT_PROP_CURRENT_TIME, mMediaPlayer.getCurrentPosition() / 1000.0); event.putDouble(EVENT_PROP_PLAYABLE_DURATION, mVideoBufferedDuration / 1000.0); //TODO:mBufferUpdateRunnable + event.putDouble(EVENT_PROP_SEEKABLE_DURATION, mVideoDuration / 1000.0); mEventEmitter.receiveEvent(getId(), Events.EVENT_PROGRESS.toString(), event); // Check for update after an interval From cf9a5fc63596d6095506b01a988af7067e907205 Mon Sep 17 00:00:00 2001 From: Andy Stanberry Date: Wed, 31 Jan 2018 17:53:37 -0500 Subject: [PATCH 14/40] Document poster prop --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 597b71ec..9a6da0f4 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ using System.Collections.Generic; // on a single screen if you like.