From 91e0206a41b365502ff17e9b5780c49ee2d7b44c Mon Sep 17 00:00:00 2001 From: sridhar Date: Thu, 24 Jan 2019 15:44:45 +0530 Subject: [PATCH 01/12] Exoplayer gradle changes Exoplayer gradle changes --- android-exoplayer/build.gradle | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/android-exoplayer/build.gradle b/android-exoplayer/build.gradle index a532956d85..4c7c3f0653 100644 --- a/android-exoplayer/build.gradle +++ b/android-exoplayer/build.gradle @@ -18,18 +18,26 @@ android { dependencies { compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" - implementation('com.google.android.exoplayer:exoplayer:2.9.3') { - exclude group: 'com.android.support' - } + // 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', '+')}" implementation "com.android.support:support-compat:${safeExtGet('supportLibVersion', '+')}" implementation "com.android.support:support-media-compat:${safeExtGet('supportLibVersion', '+')}" - implementation('com.google.android.exoplayer:extension-okhttp:2.9.3') { - exclude group: 'com.squareup.okhttp3', module: 'okhttp' - } + // implementation('com.google.android.exoplayer:extension-okhttp:2.9.3') { + // exclude group: 'com.squareup.okhttp3', module: 'okhttp' + // } + implementation 'com.squareup.okhttp3:okhttp:3.12.1' } From 172954de5ae5a09bff92c9808dc1ebf1adb3a7f1 Mon Sep 17 00:00:00 2001 From: sridhar Date: Thu, 24 Jan 2019 18:49:37 +0530 Subject: [PATCH 02/12] Feature implementation: Failure Retry Count Feature implementation: Failure Retry Count --- Video.js | 1 + .../exoplayer/ReactExoplayerView.java | 17 ++++++++++++++--- .../exoplayer/ReactExoplayerViewManager.java | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Video.js b/Video.js index 92544467c0..703aef5e00 100644 --- a/Video.js +++ b/Video.js @@ -339,6 +339,7 @@ Video.propTypes = { // Opaque type returned by require('./video.mp4') PropTypes.number ]), + failureRetryCount: PropTypes.number, maxBitRate: PropTypes.number, resizeMode: PropTypes.string, poster: PropTypes.string, 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 64c8a4043f..0802147911 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -114,6 +114,7 @@ class ReactExoplayerView extends FrameLayout implements private boolean isBuffering; private float rate = 1f; private float audioVolume = 1f; + private int failureRetryCount = 3; private int maxBitRate = 0; private long seekTime = C.TIME_UNSET; @@ -310,12 +311,17 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension) { switch (type) { case C.TYPE_SS: return new SsMediaSource(uri, buildDataSourceFactory(false), - new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null); + new DefaultSsChunkSource.Factory(mediaDataSourceFactory), + failureRetryCount, SsMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS, + mainHandler, null); case C.TYPE_DASH: return new DashMediaSource(uri, buildDataSourceFactory(false), - new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null); + new DefaultDashChunkSource.Factory(mediaDataSourceFactory), + failureRetryCount, DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS, + mainHandler, null); case C.TYPE_HLS: - return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null); + return new HlsMediaSource(uri, mediaDataSourceFactory, + failureRetryCount, mainHandler, null); case C.TYPE_OTHER: return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, null); @@ -998,6 +1004,11 @@ public void setMaxBitRateModifier(int newMaxBitRate) { } } + public void setfailureRetryCountModifier(int newFailureRetryCount) { + failureRetryCount = newFailureRetryCount; + releasePlayer(); + initializePlayer(); + } public void setPlayInBackground(boolean playInBackground) { this.playInBackground = playInBackground; diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index 31bd8e08be..de162f97ab 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -48,6 +48,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Thu, 24 Jan 2019 18:59:54 +0530 Subject: [PATCH 03/12] Doc changes for retry count implementation Doc changes for retry count implementation --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 05337141f5..5ba6418d74 100644 --- a/README.md +++ b/README.md @@ -269,6 +269,7 @@ var styles = StyleSheet.create({ * [id](#id) * [ignoreSilentSwitch](#ignoresilentswitch) * [maxBitRate](#maxbitrate) +* [failureRetryCount](#failureRetryCount) * [muted](#muted) * [paused](#paused) * [playInBackground](#playinbackground) @@ -475,6 +476,18 @@ maxBitRate={2000000} // 2 megabits Platforms: Android ExoPlayer, iOS +#### failureRetryCount +Sets the number of times the media play failures to be retried. Useful to recover from transient internet faiures. Recoverable failures are retried before reporting the error to the application. + +Default: 3. Retry 3 times. + +Example: +``` +failureRetryCount={5} // retry 5 times +``` + +Platforms: Android ExoPlayer + #### muted Controls whether the audio is muted * **false (default)** - Don't mute audio From 88e9ed6c08ba25b01e9f639bd13a3ddfdaa13ce2 Mon Sep 17 00:00:00 2001 From: sridhar Date: Thu, 24 Jan 2019 19:02:26 +0530 Subject: [PATCH 04/12] Gradle changes reverted back Gradle changes reverted back --- android-exoplayer/build.gradle | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/android-exoplayer/build.gradle b/android-exoplayer/build.gradle index 4c7c3f0653..d7914b473b 100644 --- a/android-exoplayer/build.gradle +++ b/android-exoplayer/build.gradle @@ -18,26 +18,18 @@ android { dependencies { compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" - // 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') + implementation('com.google.android.exoplayer:exoplayer:2.9.3') { + exclude group: 'com.android.support' + } // All support libs must use the same version implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '+')}" implementation "com.android.support:support-compat:${safeExtGet('supportLibVersion', '+')}" implementation "com.android.support:support-media-compat:${safeExtGet('supportLibVersion', '+')}" - // implementation('com.google.android.exoplayer:extension-okhttp:2.9.3') { - // exclude group: 'com.squareup.okhttp3', module: 'okhttp' - // } - + implementation('com.google.android.exoplayer:extension-okhttp:2.9.3') { + exclude group: 'com.squareup.okhttp3', module: 'okhttp' + } implementation 'com.squareup.okhttp3:okhttp:3.12.1' -} +} \ No newline at end of file From 47875ed2867da9697b180d56efb75a7c67bd5eda Mon Sep 17 00:00:00 2001 From: sridhar Date: Thu, 24 Jan 2019 19:06:11 +0530 Subject: [PATCH 05/12] Doc modifications as per alplabetical order Doc modifications as per alplabetical order --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5ba6418d74..706e3fef27 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,7 @@ var styles = StyleSheet.create({ * [audioOnly](#audioonly) * [bufferConfig](#bufferconfig) * [controls](#controls) +* [failureRetryCount](#failureRetryCount) * [filter](#filter) * [filterEnabled](#filterEnabled) * [fullscreen](#fullscreen) @@ -269,7 +270,6 @@ var styles = StyleSheet.create({ * [id](#id) * [ignoreSilentSwitch](#ignoresilentswitch) * [maxBitRate](#maxbitrate) -* [failureRetryCount](#failureRetryCount) * [muted](#muted) * [paused](#paused) * [playInBackground](#playinbackground) @@ -364,6 +364,18 @@ Controls are not available Android because the system does not provide a stock s Platforms: iOS, react-native-dom +#### failureRetryCount +Sets the number of times the media play failures to be retried. Useful to recover from transient internet faiures. Recoverable failures are retried before reporting the error to the application. + +Default: 3. Retry 3 times. + +Example: +``` +failureRetryCount={5} // retry 5 times +``` + +Platforms: Android ExoPlayer + #### filter Add video filter * **FilterType.NONE (default)** - No Filter @@ -476,18 +488,6 @@ maxBitRate={2000000} // 2 megabits Platforms: Android ExoPlayer, iOS -#### failureRetryCount -Sets the number of times the media play failures to be retried. Useful to recover from transient internet faiures. Recoverable failures are retried before reporting the error to the application. - -Default: 3. Retry 3 times. - -Example: -``` -failureRetryCount={5} // retry 5 times -``` - -Platforms: Android ExoPlayer - #### muted Controls whether the audio is muted * **false (default)** - Don't mute audio From 8dd782d91e78fb54e663549a3e9c9a55ef3796c8 Mon Sep 17 00:00:00 2001 From: sridhar Date: Thu, 24 Jan 2019 19:25:32 +0530 Subject: [PATCH 06/12] updated changelog for PR 1448 updated changelog for PR 1448 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a19ba40c..a5f2a00bd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * 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) +* Recovery from transient internet failures and props to configure the custom retry count [#1448](https://github.com/react-native-community/react-native-video/pull/1448) ### 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 938cfd64a59c257e596b70cc5513399ae974d624 Mon Sep 17 00:00:00 2001 From: sridhar Date: Wed, 30 Jan 2019 22:43:12 +0530 Subject: [PATCH 07/12] Defect fix for issue #1460 Defect fix: https://github.com/react-native-community/react-native-video/issues/1460 --- .../brentvatne/exoplayer/ReactExoplayerView.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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 0802147911..655e4e286e 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -876,7 +876,7 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) { TrackGroup group = groups.get(i); for (int j = 0; j < group.length; j++) { Format format = group.getFormat(j); - if (format.height == value.asInt()) { + if (format.height == height) { groupIndex = i; tracks[0] = j; break; @@ -894,14 +894,12 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) { groupIndex = getGroupIndexForDefaultLocale(groups); } - if (groupIndex == C.INDEX_UNSET && trackType == C.TRACK_TYPE_VIDEO) { // Video auto - if (groups.length != 0) { - TrackGroup group = groups.get(0); - tracks = new int[group.length]; - groupIndex = 0; - for (int j = 0; j < group.length; j++) { - tracks[j] = j; - } + if (groupIndex == C.INDEX_UNSET && trackType == C.TRACK_TYPE_VIDEO && groups.length > 0) { // Video auto + TrackGroup group = groups.get(0); + tracks = new int[group.length]; + groupIndex = 0; + for (int j = 0; j < group.length; j++) { + tracks[j] = j; } } else if (groupIndex == C.INDEX_UNSET) { trackSelector.setParameters(disableParameters); From 77411f2d0f49a04f954e9465d674c5064af51bbf Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 10 Feb 2019 19:21:02 -0800 Subject: [PATCH 08/12] Rename failureRetryCount to minLoadRetryCount --- Video.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Video.js b/Video.js index 703aef5e00..78b68a8c10 100644 --- a/Video.js +++ b/Video.js @@ -339,7 +339,7 @@ Video.propTypes = { // Opaque type returned by require('./video.mp4') PropTypes.number ]), - failureRetryCount: PropTypes.number, + minLoadRetryCount: PropTypes.number, maxBitRate: PropTypes.number, resizeMode: PropTypes.string, poster: PropTypes.string, From 35250fa8c4380997341a803d7e73bf25e6680315 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 10 Feb 2019 19:45:31 -0800 Subject: [PATCH 09/12] Rename failureRetryCount to minLoadRetryCount --- .../com/brentvatne/exoplayer/ReactExoplayerView.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 655e4e286e..632127c342 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -114,7 +114,7 @@ class ReactExoplayerView extends FrameLayout implements private boolean isBuffering; private float rate = 1f; private float audioVolume = 1f; - private int failureRetryCount = 3; + private int minLoadRetryCount = 3; private int maxBitRate = 0; private long seekTime = C.TIME_UNSET; @@ -312,16 +312,16 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension) { case C.TYPE_SS: return new SsMediaSource(uri, buildDataSourceFactory(false), new DefaultSsChunkSource.Factory(mediaDataSourceFactory), - failureRetryCount, SsMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS, + minLoadRetryCount, SsMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS, mainHandler, null); case C.TYPE_DASH: return new DashMediaSource(uri, buildDataSourceFactory(false), new DefaultDashChunkSource.Factory(mediaDataSourceFactory), - failureRetryCount, DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS, + minLoadRetryCount, DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS, mainHandler, null); case C.TYPE_HLS: return new HlsMediaSource(uri, mediaDataSourceFactory, - failureRetryCount, mainHandler, null); + minLoadRetryCount, mainHandler, null); case C.TYPE_OTHER: return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, null); @@ -1002,8 +1002,8 @@ public void setMaxBitRateModifier(int newMaxBitRate) { } } - public void setfailureRetryCountModifier(int newFailureRetryCount) { - failureRetryCount = newFailureRetryCount; + public void setMinLoadRetryCountModifier(int newMinLoadRetryCount) { + minLoadRetryCount = newMinLoadRetryCount; releasePlayer(); initializePlayer(); } From e4763c9d1034e9659a5091921e79d1c5053ac5a6 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 10 Feb 2019 19:47:07 -0800 Subject: [PATCH 10/12] Rename failureRetryCount to minLoadRetryCount --- .../brentvatne/exoplayer/ReactExoplayerViewManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index de162f97ab..ff1b9a9ef6 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -48,7 +48,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Sun, 10 Feb 2019 19:54:57 -0800 Subject: [PATCH 11/12] Rename failureRetryCount to minLoadRetryCount --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 706e3fef27..5032050b16 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,6 @@ var styles = StyleSheet.create({ * [audioOnly](#audioonly) * [bufferConfig](#bufferconfig) * [controls](#controls) -* [failureRetryCount](#failureRetryCount) * [filter](#filter) * [filterEnabled](#filterEnabled) * [fullscreen](#fullscreen) @@ -270,6 +269,7 @@ var styles = StyleSheet.create({ * [id](#id) * [ignoreSilentSwitch](#ignoresilentswitch) * [maxBitRate](#maxbitrate) +* [minLoadRetryCount](#minLoadRetryCount) * [muted](#muted) * [paused](#paused) * [playInBackground](#playinbackground) @@ -364,18 +364,6 @@ Controls are not available Android because the system does not provide a stock s Platforms: iOS, react-native-dom -#### failureRetryCount -Sets the number of times the media play failures to be retried. Useful to recover from transient internet faiures. Recoverable failures are retried before reporting the error to the application. - -Default: 3. Retry 3 times. - -Example: -``` -failureRetryCount={5} // retry 5 times -``` - -Platforms: Android ExoPlayer - #### filter Add video filter * **FilterType.NONE (default)** - No Filter @@ -488,6 +476,18 @@ maxBitRate={2000000} // 2 megabits Platforms: Android ExoPlayer, iOS +#### minLoadRetryCount +Sets the minimum number of times to retry loading data before failing and reporting an error to the application. Useful to recover from transient internet failures. + +Default: 3. Retry 3 times. + +Example: +``` +minLoadRetryCount={5} // retry 5 times +``` + +Platforms: Android ExoPlayer + #### muted Controls whether the audio is muted * **false (default)** - Don't mute audio From 2898f8cb5a9ac7bfd112477b07f9bc90737e4f5d Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 10 Feb 2019 19:56:56 -0800 Subject: [PATCH 12/12] Revert changes to video group index unset code I'm guessing this change was made to cleanup the code, however it is not functionally identical and may cause issues. Revert until those can be discussed. --- .../brentvatne/exoplayer/ReactExoplayerView.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 632127c342..871fb9a8ac 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -894,12 +894,14 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) { groupIndex = getGroupIndexForDefaultLocale(groups); } - if (groupIndex == C.INDEX_UNSET && trackType == C.TRACK_TYPE_VIDEO && groups.length > 0) { // Video auto - TrackGroup group = groups.get(0); - tracks = new int[group.length]; - groupIndex = 0; - for (int j = 0; j < group.length; j++) { - tracks[j] = j; + if (groupIndex == C.INDEX_UNSET && trackType == C.TRACK_TYPE_VIDEO) { // Video auto + if (groups.length != 0) { + TrackGroup group = groups.get(0); + tracks = new int[group.length]; + groupIndex = 0; + for (int j = 0; j < group.length; j++) { + tracks[j] = j; + } } } else if (groupIndex == C.INDEX_UNSET) { trackSelector.setParameters(disableParameters);