From 55e0e4dcfa7f67cdc28ea53738dff46344a9ed04 Mon Sep 17 00:00:00 2001 From: Charlie Martin Date: Sat, 4 Aug 2018 17:28:33 -0400 Subject: [PATCH 01/21] Remove flash between poster and video This resolves https://github.com/react-native-community/react-native-video/issues/1128 --- Video.js | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/Video.js b/Video.js index 5c6cd1d3..f351c3ff 100644 --- a/Video.js +++ b/Video.js @@ -248,35 +248,21 @@ export default class Video extends Component { onAudioBecomingNoisy: this._onAudioBecomingNoisy, }); - if (this.props.poster && this.state.showPoster) { - const posterStyle = { - position: 'absolute', - left: 0, - top: 0, - right: 0, - bottom: 0, - resizeMode: this.props.posterResizeMode || 'contain' - }; - - return ( - - - - - ); - } + const posterStyle = { + ...StyleSheet.absoluteFillObject, + resizeMode: this.props.posterResizeMode || 'contain', + }; return ( - + + + {this.props.poster && + this.state.showPoster && ( + + + + )} + ); } } From 33d9acdf5de831198f3a36202a6e8bbc565da260 Mon Sep 17 00:00:00 2001 From: Matthew Herz Date: Thu, 6 Sep 2018 12:56:36 -0700 Subject: [PATCH 02/21] Fix missing TargetApi import The build was producing a "cannot find symbol class TargetApi" error without that line. --- 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 b7c2eec5..3ff17a1f 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -1,6 +1,7 @@ package com.brentvatne.react; import android.annotation.SuppressLint; +import android.annotation.TargetApi; import android.app.Activity; import android.content.res.AssetFileDescriptor; import android.graphics.Matrix; From bbacb953458fffc38cba846d1e5b27e3066e78f1 Mon Sep 17 00:00:00 2001 From: David Narbutovich Date: Wed, 12 Sep 2018 11:27:36 +0300 Subject: [PATCH 03/21] Update TextTrackType.js Remove not needed import --- TextTrackType.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/TextTrackType.js b/TextTrackType.js index caff65a9..9dc14077 100644 --- a/TextTrackType.js +++ b/TextTrackType.js @@ -1,5 +1,3 @@ -import keyMirror from 'keymirror'; - export default { SRT: 'application/x-subrip', TTML: 'application/ttml+xml', From a135dd346e5e847e1f0d4c864ea57a67881a3848 Mon Sep 17 00:00:00 2001 From: David Narbutovich Date: Wed, 12 Sep 2018 23:01:28 +0300 Subject: [PATCH 04/21] Reduce package size --- .npmignore | 1 - package.json | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) delete mode 100644 .npmignore diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 46b411bf..00000000 --- a/.npmignore +++ /dev/null @@ -1 +0,0 @@ -/examples diff --git a/package.json b/package.json index 3051b567..cfef620d 100644 --- a/package.json +++ b/package.json @@ -44,5 +44,14 @@ "android": { "sourceDir": "./android-exoplayer" } - } + }, + "files":[ + "android-exoplayer", + "android", + "ios", + "windows", + "TextTrackType.js", + "react-native-video.podspec", + "VideoResizeMode.js" + ] } \ No newline at end of file From 5e360608af485bdec2ddaf61b782e4c5a76d63c5 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Wed, 12 Sep 2018 19:38:11 -0700 Subject: [PATCH 05/21] Return unset track index when there are no track available (#1190) --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 4 ++++ 1 file changed, 4 insertions(+) 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 e098c72a..0c1a178f 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -830,6 +830,10 @@ class ReactExoplayerView extends FrameLayout implements } private int getTrackIndexForDefaultLocale(TrackGroupArray groups) { + if (groups.length == 0) { // Avoid a crash if we try to select a non-existant group + return C.INDEX_UNSET; + } + int trackIndex = 0; // default if no match String locale2 = Locale.getDefault().getLanguage(); // 2 letter code String locale3 = Locale.getDefault().getISO3Language(); // 3 letter code From b0c0ac10f437a40b4d7d6184d21cdbbdea2886ed Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Wed, 12 Sep 2018 19:42:11 -0700 Subject: [PATCH 06/21] Avoid crash on ExoPlayer when there are no tracks to choose from --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ac26914..2bc5b674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Support video caching for iOS [#955](https://github.com/react-native-community/react-native-video/pull/955) * Video caching cleanups [#1172](https://github.com/react-native-community/react-native-video/pull/1172) * Add ipod-library support [#926](https://github.com/react-native-community/react-native-video/pull/926/files) +* Fix crash on ExoPlayer when there are no audio tracks [#1233](https://github.com/react-native-community/react-native-video/pull/1233) ### Version 3.2.0 * Basic fullscreen support for Android MediaPlayer [#1138](https://github.com/react-native-community/react-native-video/pull/1138) From d7efcf315faeb7711b85f639d06030e726a7fd39 Mon Sep 17 00:00:00 2001 From: Artur Jaworski Date: Thu, 13 Sep 2018 14:06:12 +0200 Subject: [PATCH 07/21] introducing onExternalPlaybackActiveChange --- Video.js | 8 ++++++++ ios/Video/RCTVideo.h | 1 + ios/Video/RCTVideo.m | 20 ++++++++++++++++++++ ios/Video/RCTVideoManager.m | 1 + 4 files changed, 30 insertions(+) diff --git a/Video.js b/Video.js index e8203b8b..ad9919b7 100644 --- a/Video.js +++ b/Video.js @@ -172,6 +172,12 @@ export default class Video extends Component { this.props.onPlaybackRateChange(event.nativeEvent); } }; + + _onExternalPlaybackChange = (event) => { + if (this.props.onExternalPlaybackChange) { + this.props.onExternalPlaybackChange(event.nativeEvent); + } + } _onAudioBecomingNoisy = () => { if (this.props.onAudioBecomingNoisy) { @@ -246,6 +252,7 @@ export default class Video extends Component { onPlaybackRateChange: this._onPlaybackRateChange, onAudioFocusChanged: this._onAudioFocusChanged, onAudioBecomingNoisy: this._onAudioBecomingNoisy, + onExternalPlaybackChange: this._onExternalPlaybackChange, }); if (this.props.poster && this.state.showPoster) { @@ -379,6 +386,7 @@ Video.propTypes = { onPlaybackRateChange: PropTypes.func, onAudioFocusChanged: PropTypes.func, onAudioBecomingNoisy: PropTypes.func, + onExternalPlaybackChange: PropTypes.func, /* Required by react-native */ scaleX: PropTypes.number, diff --git a/ios/Video/RCTVideo.h b/ios/Video/RCTVideo.h index b2296c5d..472cb2ff 100644 --- a/ios/Video/RCTVideo.h +++ b/ios/Video/RCTVideo.h @@ -35,6 +35,7 @@ @property (nonatomic, copy) RCTBubblingEventBlock onPlaybackStalled; @property (nonatomic, copy) RCTBubblingEventBlock onPlaybackResume; @property (nonatomic, copy) RCTBubblingEventBlock onPlaybackRateChange; +@property (nonatomic, copy) RCTBubblingEventBlock onExternalPlaybackChange; - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index 9fe30b63..45389799 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -12,6 +12,7 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; static NSString *const readyForDisplayKeyPath = @"readyForDisplay"; static NSString *const playbackRate = @"rate"; static NSString *const timedMetadata = @"timedMetadata"; +static NSString *const externalPlaybackActive = @"externalPlaybackActive"; static int const RCTVideoUnset = -1; @@ -35,6 +36,7 @@ static int const RCTVideoUnset = -1; /* Required to publish events */ RCTEventDispatcher *_eventDispatcher; BOOL _playbackRateObserverRegistered; + BOOL _isExternalPlaybackActiveObserverRegistered; BOOL _videoLoadStarted; bool _pendingSeek; @@ -74,6 +76,7 @@ static int const RCTVideoUnset = -1; _eventDispatcher = eventDispatcher; _playbackRateObserverRegistered = NO; + _isExternalPlaybackActiveObserverRegistered = NO; _playbackStalled = NO; _rate = 1.0; _volume = 1.0; @@ -333,12 +336,19 @@ static int const RCTVideoUnset = -1; [_player removeObserver:self forKeyPath:playbackRate context:nil]; _playbackRateObserverRegistered = NO; } + if (_isExternalPlaybackActiveObserverRegistered) { + [_player removeObserver:self forKeyPath:externalPlaybackActive context:nil]; + _isExternalPlaybackActiveObserverRegistered = NO; + } _player = [AVPlayer playerWithPlayerItem:_playerItem]; _player.actionAtItemEnd = AVPlayerActionAtItemEndNone; [_player addObserver:self forKeyPath:playbackRate options:0 context:nil]; _playbackRateObserverRegistered = YES; + + [_player addObserver:self forKeyPath:externalPlaybackActive options:0 context:nil]; + _isExternalPlaybackActiveObserverRegistered = YES; [self addPlayerTimeObserver]; @@ -646,6 +656,12 @@ static int const RCTVideoUnset = -1; _playbackStalled = NO; } } + else if([keyPath isEqualToString:externalPlaybackActive]) { + if(self.onExternalPlaybackChange) { + self.onExternalPlaybackChange(@{@"isExternalPlaybackActive": [NSNumber numberWithBool:_player.isExternalPlaybackActive], + @"target": self.reactTag}); + } + } } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } @@ -1290,6 +1306,10 @@ static int const RCTVideoUnset = -1; [_player removeObserver:self forKeyPath:playbackRate context:nil]; _playbackRateObserverRegistered = NO; } + if (_isExternalPlaybackActiveObserverRegistered) { + [_player removeObserver:self forKeyPath:externalPlaybackActive context:nil]; + _isExternalPlaybackActiveObserverRegistered = NO; + } _player = nil; [self removePlayerLayer]; diff --git a/ios/Video/RCTVideoManager.m b/ios/Video/RCTVideoManager.m index e0e0162e..190a1663 100644 --- a/ios/Video/RCTVideoManager.m +++ b/ios/Video/RCTVideoManager.m @@ -56,6 +56,7 @@ RCT_EXPORT_VIEW_PROPERTY(onReadyForDisplay, RCTBubblingEventBlock); RCT_EXPORT_VIEW_PROPERTY(onPlaybackStalled, RCTBubblingEventBlock); RCT_EXPORT_VIEW_PROPERTY(onPlaybackResume, RCTBubblingEventBlock); RCT_EXPORT_VIEW_PROPERTY(onPlaybackRateChange, RCTBubblingEventBlock); +RCT_EXPORT_VIEW_PROPERTY(onExternalPlaybackChange, RCTBubblingEventBlock); - (NSDictionary *)constantsToExport { From 5e2b49c34377c10668681ea4a232580a03e189d5 Mon Sep 17 00:00:00 2001 From: Artur Jaworski Date: Tue, 18 Sep 2018 09:45:12 +0200 Subject: [PATCH 08/21] readme update --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index c1dd0f0f..f0ea1091 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ var styles = StyleSheet.create({ * [onLoadStart](#onloadstart) * [onProgress](#onprogress) * [onTimedMetadata](#ontimedmetadata) +* [onExternalPlaybackChange](#onexternalplaybackchange) ### Methods * [dismissFullscreenPlayer](#dismissfullscreenplayer) @@ -721,6 +722,24 @@ Support for timed metadata on Android MediaPlayer is limited at best and only co Platforms: Android ExoPlayer, Android MediaPlayer, iOS +#### onExternalPlaybackChange +Callback function that is called when external playback mode for current playing video has changed. Mostly useful when connecting/disconnecting to Apple TV – it's called on connection/disconnection. + +Payload: + +Property | Type | Description +--- | --- | --- +isExternalPlaybackActive | boolean | Boolean indicating is external playback mode is active + +Example: +``` +{ + isExternalPlaybackActive: true +} +``` + +Platforms: iOS + ### Methods Methods operate on a ref to the Video element. You can create a ref using code like: ``` From ea4c732c9593e5db24b1d46d6284a7977d5001f7 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sat, 22 Sep 2018 15:01:51 -0700 Subject: [PATCH 09/21] Reduce package size --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc5b674..60460e2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ * Video caching cleanups [#1172](https://github.com/react-native-community/react-native-video/pull/1172) * Add ipod-library support [#926](https://github.com/react-native-community/react-native-video/pull/926/files) * Fix crash on ExoPlayer when there are no audio tracks [#1233](https://github.com/react-native-community/react-native-video/pull/1233) +* Reduce package size [#1231](https://github.com/react-native-community/react-native-video/pull/1231) +* Remove unnecessary import in TextTrackType [#1229](https://github.com/react-native-community/react-native-video/pull/1229) ### Version 3.2.0 * Basic fullscreen support for Android MediaPlayer [#1138](https://github.com/react-native-community/react-native-video/pull/1138) From 584559ea7599e90eb294020c2db888f11fe2fde1 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sat, 22 Sep 2018 15:03:22 -0700 Subject: [PATCH 10/21] Bump version to 3.2.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3051b567..13e79075 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-video", - "version": "3.2.0", + "version": "3.2.1", "description": "A