Merge pull request #1448 from sridhard/master
Feature Implementation: Recovery from transient internet failures
This commit is contained in:
commit
4424774ca3
@ -10,6 +10,7 @@
|
|||||||
* Fix text not appearing in release builds of Android apps [#1373](https://github.com/react-native-community/react-native-video/pull/1373)
|
* 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)
|
* 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)
|
* 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
|
### 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)
|
* 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)
|
||||||
|
13
README.md
13
README.md
@ -269,6 +269,7 @@ var styles = StyleSheet.create({
|
|||||||
* [id](#id)
|
* [id](#id)
|
||||||
* [ignoreSilentSwitch](#ignoresilentswitch)
|
* [ignoreSilentSwitch](#ignoresilentswitch)
|
||||||
* [maxBitRate](#maxbitrate)
|
* [maxBitRate](#maxbitrate)
|
||||||
|
* [minLoadRetryCount](#minLoadRetryCount)
|
||||||
* [muted](#muted)
|
* [muted](#muted)
|
||||||
* [paused](#paused)
|
* [paused](#paused)
|
||||||
* [playInBackground](#playinbackground)
|
* [playInBackground](#playinbackground)
|
||||||
@ -475,6 +476,18 @@ maxBitRate={2000000} // 2 megabits
|
|||||||
|
|
||||||
Platforms: Android ExoPlayer, iOS
|
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
|
#### muted
|
||||||
Controls whether the audio is muted
|
Controls whether the audio is muted
|
||||||
* **false (default)** - Don't mute audio
|
* **false (default)** - Don't mute audio
|
||||||
|
1
Video.js
1
Video.js
@ -341,6 +341,7 @@ Video.propTypes = {
|
|||||||
// Opaque type returned by require('./video.mp4')
|
// Opaque type returned by require('./video.mp4')
|
||||||
PropTypes.number
|
PropTypes.number
|
||||||
]),
|
]),
|
||||||
|
minLoadRetryCount: PropTypes.number,
|
||||||
maxBitRate: PropTypes.number,
|
maxBitRate: PropTypes.number,
|
||||||
resizeMode: PropTypes.string,
|
resizeMode: PropTypes.string,
|
||||||
poster: PropTypes.string,
|
poster: PropTypes.string,
|
||||||
|
@ -32,4 +32,4 @@ dependencies {
|
|||||||
}
|
}
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
||||||
|
|
||||||
}
|
}
|
@ -118,6 +118,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
private boolean isBuffering;
|
private boolean isBuffering;
|
||||||
private float rate = 1f;
|
private float rate = 1f;
|
||||||
private float audioVolume = 1f;
|
private float audioVolume = 1f;
|
||||||
|
private int minLoadRetryCount = 3;
|
||||||
private int maxBitRate = 0;
|
private int maxBitRate = 0;
|
||||||
private long seekTime = C.TIME_UNSET;
|
private long seekTime = C.TIME_UNSET;
|
||||||
|
|
||||||
@ -387,12 +388,17 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case C.TYPE_SS:
|
case C.TYPE_SS:
|
||||||
return new SsMediaSource(uri, buildDataSourceFactory(false),
|
return new SsMediaSource(uri, buildDataSourceFactory(false),
|
||||||
new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
|
new DefaultSsChunkSource.Factory(mediaDataSourceFactory),
|
||||||
|
minLoadRetryCount, SsMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS,
|
||||||
|
mainHandler, null);
|
||||||
case C.TYPE_DASH:
|
case C.TYPE_DASH:
|
||||||
return new DashMediaSource(uri, buildDataSourceFactory(false),
|
return new DashMediaSource(uri, buildDataSourceFactory(false),
|
||||||
new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
|
new DefaultDashChunkSource.Factory(mediaDataSourceFactory),
|
||||||
|
minLoadRetryCount, DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS,
|
||||||
|
mainHandler, null);
|
||||||
case C.TYPE_HLS:
|
case C.TYPE_HLS:
|
||||||
return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
|
return new HlsMediaSource(uri, mediaDataSourceFactory,
|
||||||
|
minLoadRetryCount, mainHandler, null);
|
||||||
case C.TYPE_OTHER:
|
case C.TYPE_OTHER:
|
||||||
return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
|
return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
|
||||||
mainHandler, null);
|
mainHandler, null);
|
||||||
@ -951,7 +957,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
TrackGroup group = groups.get(i);
|
TrackGroup group = groups.get(i);
|
||||||
for (int j = 0; j < group.length; j++) {
|
for (int j = 0; j < group.length; j++) {
|
||||||
Format format = group.getFormat(j);
|
Format format = group.getFormat(j);
|
||||||
if (format.height == value.asInt()) {
|
if (format.height == height) {
|
||||||
groupIndex = i;
|
groupIndex = i;
|
||||||
tracks[0] = j;
|
tracks[0] = j;
|
||||||
break;
|
break;
|
||||||
@ -1079,6 +1085,11 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMinLoadRetryCountModifier(int newMinLoadRetryCount) {
|
||||||
|
minLoadRetryCount = newMinLoadRetryCount;
|
||||||
|
releasePlayer();
|
||||||
|
initializePlayer();
|
||||||
|
}
|
||||||
|
|
||||||
public void setPlayInBackground(boolean playInBackground) {
|
public void setPlayInBackground(boolean playInBackground) {
|
||||||
this.playInBackground = playInBackground;
|
this.playInBackground = playInBackground;
|
||||||
|
@ -48,6 +48,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
private static final String PROP_REPORT_BANDWIDTH = "reportBandwidth";
|
private static final String PROP_REPORT_BANDWIDTH = "reportBandwidth";
|
||||||
private static final String PROP_SEEK = "seek";
|
private static final String PROP_SEEK = "seek";
|
||||||
private static final String PROP_RATE = "rate";
|
private static final String PROP_RATE = "rate";
|
||||||
|
private static final String PROP_MIN_LOAD_RETRY_COUNT = "minLoadRetryCount";
|
||||||
private static final String PROP_MAXIMUM_BIT_RATE = "maxBitRate";
|
private static final String PROP_MAXIMUM_BIT_RATE = "maxBitRate";
|
||||||
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
|
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
|
||||||
private static final String PROP_DISABLE_FOCUS = "disableFocus";
|
private static final String PROP_DISABLE_FOCUS = "disableFocus";
|
||||||
@ -231,6 +232,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
videoView.setMaxBitRateModifier(maxBitRate);
|
videoView.setMaxBitRateModifier(maxBitRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactProp(name = PROP_MIN_LOAD_RETRY_COUNT)
|
||||||
|
public void minLoadRetryCount(final ReactExoplayerView videoView, final int minLoadRetryCount) {
|
||||||
|
videoView.setMinLoadRetryCountModifier(minLoadRetryCount);
|
||||||
|
}
|
||||||
|
|
||||||
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
|
@ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
|
||||||
public void setPlayInBackground(final ReactExoplayerView videoView, final boolean playInBackground) {
|
public void setPlayInBackground(final ReactExoplayerView videoView, final boolean playInBackground) {
|
||||||
videoView.setPlayInBackground(playInBackground);
|
videoView.setPlayInBackground(playInBackground);
|
||||||
|
Loading…
Reference in New Issue
Block a user