From 937eec0eaedca88536c9980115a87d8d02a4ec13 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 21:50:12 -0800 Subject: [PATCH 01/12] Document onBandwidthUpdate & video track selection --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/README.md b/README.md index d5dcaf7375..0a99eece47 100644 --- a/README.md +++ b/README.md @@ -278,9 +278,11 @@ var styles = StyleSheet.create({ * [progressUpdateInterval](#progressupdateinterval) * [rate](#rate) * [repeat](#repeat) +* [reportBandwidth](#reportbandwidth) * [resizeMode](#resizemode) * [selectedAudioTrack](#selectedaudiotrack) * [selectedTextTrack](#selectedtexttrack) +* [selectedVideoTrack](#selectedvideotrack) * [source](#source) * [stereoPan](#stereopan) * [textTracks](#texttracks) @@ -289,6 +291,7 @@ var styles = StyleSheet.create({ ### Event props * [onAudioBecomingNoisy](#onaudiobecomingnoisy) +* [onBandwidthUpdate](#onbandwidthupdate) * [onEnd](#onend) * [onExternalPlaybackChange](#onexternalplaybackchange) * [onFullscreenPlayerWillPresent](#onfullscreenplayerwillpresent) @@ -542,6 +545,14 @@ Determine whether to repeat the video when the end is reached Platforms: all +#### reportBandwidth +Determine whether to generate onBandwidthUpdate events. This is needed due to the high frequency of these events on ExoPlayer. + +* **false (default)** - Generate onBandwidthUpdate events +* **true** - Don't generate onBandwidthUpdate events + +Platforms: Android ExoPlayer + #### resizeMode Determines how to resize the video when the frame doesn't match the raw video dimensions. * **"none" (default)** - Don't apply resize @@ -613,6 +624,35 @@ If a track matching the specified Type (and Value if appropriate) is unavailable Platforms: Android ExoPlayer, iOS +#### selectedVideoTrack +Configure which video track should be played. By default, the player uses Adaptive Bitrate Streaming to automatically select the stream it thinks will perform best based on available bandwidth. + +``` +selectedVideoTrack={{ + type: Type, + value: Value +}} +``` + +Example: +``` +selectedVideoTrack={{ + type: "resolution", + value: 480 +}} +``` + +Type | Value | Description +--- | --- | --- +"auto" (default) | N/A | Let the player determine which track to play using ABR +"disabled" | N/A | Turn off video +"resolution" | number | Play the video track with the height specified, e.g. 480 for the 480p stream +"index" | number | Play the video track with the index specified as the value, e.g. 0 + +If a track matching the specified Type (and Value if appropriate) is unavailable, ABR will be used. + +Platforms: Android ExoPlayer + #### source Sets the media source. You can pass an asset loaded via require or an object with a uri. @@ -748,6 +788,26 @@ Payload: none Platforms: Android ExoPlayer, iOS +#### onBandwidthUpdate +Callback function that is called when the available bandwidth changes. + +Payload: + +Property | Type | Description +--- | --- | --- +bitrate | number | The estimated bitrate in bits/sec + +Example: +``` +{ + bitrate: 1000000 +} +``` + +Note: On Android ExoPlayer, you must set the [reportBandwidth](#reportbandwidth) prop to enable this event. This is due to the high volume of events generated. + +Platforms: Android ExoPlayer, iOS + #### onEnd Callback function that is called when the player reaches the end of the media. From 3c313e2e61a8283f03ac9104957bcd6e29e412ed Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 21:57:31 -0800 Subject: [PATCH 02/12] Revert build.gradle changes from video track selection PR --- android-exoplayer/build.gradle | 6 ------ 1 file changed, 6 deletions(-) diff --git a/android-exoplayer/build.gradle b/android-exoplayer/build.gradle index 614d010cd0..a532956d85 100644 --- a/android-exoplayer/build.gradle +++ b/android-exoplayer/build.gradle @@ -21,12 +21,6 @@ dependencies { implementation('com.google.android.exoplayer:exoplayer:2.9.3') { exclude group: 'com.android.support' } - implementation project(':exoplayer-library-core') - implementation project(':exoplayer-library-dash') - implementation project(':exoplayer-library-ui') - implementation project(':exoplayer-library-smoothstreaming') - implementation project(':exoplayer-library-hls') - implementation project(':exoplayer-extension-okhttp') // All support libs must use the same version implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '+')}" From d249b08c252e084a5d347a00e2898ee3f3fa7ae6 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 22:04:04 -0800 Subject: [PATCH 03/12] Add dependencies needed for Haul --- package.json | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0c690a04f4..57ae874ed1 100644 --- a/package.json +++ b/package.json @@ -28,15 +28,19 @@ "url": "git@github.com:brentvatne/react-native-video.git" }, "devDependencies": { - "eslint": "1.10.3", "babel-eslint": "5.0.0-beta8", + "eslint": "1.10.3", + "eslint-config-airbnb": "4.0.0", "eslint-plugin-react": "3.16.1", - "eslint-config-airbnb": "4.0.0" + "react": "^16.7.0", + "react-dom": "^16.7.0", + "react-hot-loader": "^4.6.3", + "react-native": "^0.57.8" }, "dependencies": { - "keymirror": "0.1.1", + "keymirror": "^0.1.1", "prop-types": "^15.5.10", - "shaka-player": "2.4.4" + "shaka-player": "^2.4.4" }, "scripts": { "test": "node_modules/.bin/eslint *.js" @@ -46,7 +50,7 @@ "sourceDir": "./android-exoplayer" } }, - "files":[ + "files": [ "android-exoplayer", "android", "dom", From ba439cc319dd380fe2d0e7efba2872bc4951d380 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 22:04:28 -0800 Subject: [PATCH 04/12] Add video track selection & onBandwidthUpdate --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce3a0d4cfd..24a19ba40c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ## Changelog -### Next Version +### Version 4.3.0 * Fix iOS video not displaying after switching source [#1395](https://github.com/react-native-community/react-native-video/pull/1395) * Add the filterEnabled flag, fixes iOS video start time regression [#1384](https://github.com/react-native-community/react-native-video/pull/1384) * Fix text not appearing in release builds of Android apps [#1373](https://github.com/react-native-community/react-native-video/pull/1373) * Update to ExoPlayer 2.9.3 [#1406](https://github.com/react-native-community/react-native-video/pull/1406) +* Add video track selection & onBandwidthUpdate [#1199](https://github.com/react-native-community/react-native-video/pull/1199) ### Version 4.2.0 * Don't initialize filters on iOS unless a filter is set. This was causing a startup performance regression [#1360](https://github.com/react-native-community/react-native-video/pull/1360) From fb5f87bc9b9d89c9ba2c141c31ed6289666edf70 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 22:06:50 -0800 Subject: [PATCH 05/12] Disable onBandwidthUpdate for iOS since it's not working yet --- README.md | 2 +- ios/Video/RCTVideo.m | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a99eece47..9ee34399ce 100644 --- a/README.md +++ b/README.md @@ -806,7 +806,7 @@ Example: Note: On Android ExoPlayer, you must set the [reportBandwidth](#reportbandwidth) prop to enable this event. This is due to the high volume of events generated. -Platforms: Android ExoPlayer, iOS +Platforms: Android ExoPlayer #### onEnd Callback function that is called when the player reaches the end of the media. diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index b71bbf2853..52b0342a6b 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -719,9 +719,11 @@ - (void)handleAVPlayerAccess:(NSNotification *)notification { AVPlayerItemAccessLog *accessLog = [((AVPlayerItem *)notification.object) accessLog]; AVPlayerItemAccessLogEvent *lastEvent = accessLog.events.lastObject; + /* TODO: get this working if (self.onBandwidthUpdate) { self.onBandwidthUpdate(@{@"bitrate": [NSNumber numberWithFloat:lastEvent.observedBitrate]}); } + */ } - (void)playbackStalled:(NSNotification *)notification From 9a809e22d87a6b92f38dc01aa5e8bca5fb268104 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 22:08:18 -0800 Subject: [PATCH 06/12] Fix mismatched bitrate vars --- .../main/java/com/brentvatne/exoplayer/VideoEventEmitter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java index b46b66d6d4..00f51c94cd 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java @@ -178,7 +178,7 @@ void progressChanged(double currentPosition, double bufferedDuration, double see void bandwidthReport(double bitRateEstimate) { WritableMap event = Arguments.createMap(); - event.putDouble(EVENT_PROP_BITRATE, bitRate); + event.putDouble(EVENT_PROP_BITRATE, bitRateEstimate); receiveEvent(EVENT_BANDWIDTH, event); } From 0339727fab79c6f5a1b0858ccc3f29afbb41e59d Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 31 Dec 2018 22:12:13 -0800 Subject: [PATCH 07/12] Version 4.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57ae874ed1..d1bbd6e759 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-video", - "version": "4.2.1", + "version": "4.3.0", "description": "A