Rename to bufferConfig and use stopPlayback
This commit is contained in:
parent
f46a00c4d4
commit
cd75e72180
@ -480,8 +480,9 @@ Adjust the volume.
|
||||
|
||||
Platforms: all
|
||||
|
||||
#### loadControl
|
||||
Adjust the load control parameters: minBufferMs, maxBufferMs, bufferForPlaybackMs and playbackAfterRebufferMs.
|
||||
#### bufferConfig
|
||||
Adjust the video load control parameters: minBufferMs, maxBufferMs, bufferForPlaybackMs and playbackAfterRebufferMs.
|
||||
Note: these values can not be changed after the video component is loaded.
|
||||
|
||||
Property | Description
|
||||
--- | ---
|
||||
@ -491,7 +492,7 @@ bufferForPlaybackMs | The default duration of media that must be buffered for pl
|
||||
playbackAfterRebufferMs | The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action.
|
||||
|
||||
```
|
||||
loadControl={{
|
||||
bufferConfig={{
|
||||
minBufferMs: number,
|
||||
maxBufferMs: number,
|
||||
bufferForPlaybackMs: number,
|
||||
@ -501,7 +502,7 @@ loadControl={{
|
||||
|
||||
Example with default values:
|
||||
```
|
||||
loadControl={{
|
||||
bufferConfig={{
|
||||
minBufferMs: 15000,
|
||||
maxBufferMs: 50000,
|
||||
bufferForPlaybackMs: 2500,
|
||||
|
2
Video.js
2
Video.js
@ -345,7 +345,7 @@ Video.propTypes = {
|
||||
paused: PropTypes.bool,
|
||||
muted: PropTypes.bool,
|
||||
volume: PropTypes.number,
|
||||
loadControl: PropTypes.shape({
|
||||
bufferConfig: PropTypes.shape({
|
||||
minBufferMs: PropTypes.number,
|
||||
maxBufferMs: PropTypes.number,
|
||||
bufferForPlaybackMs: PropTypes.number,
|
||||
|
@ -940,13 +940,12 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
exoPlayerView.setUseTextureView(useTextureView);
|
||||
}
|
||||
|
||||
public void setLoadControl(int newMinBufferMs, int newMaxBufferMs, int newBufferForPlaybackMs, int newBufferForPlaybackAfterRebufferMs) {
|
||||
player.release();
|
||||
this.player = null;
|
||||
this.minBufferMs = newMinBufferMs;
|
||||
this.maxBufferMs = newMaxBufferMs;
|
||||
this.bufferForPlaybackMs = newBufferForPlaybackMs;
|
||||
this.bufferForPlaybackAfterRebufferMs = newBufferForPlaybackAfterRebufferMs;
|
||||
public void setBufferConfig(int newMinBufferMs, int newMaxBufferMs, int newBufferForPlaybackMs, int newBufferForPlaybackAfterRebufferMs) {
|
||||
stopPlayback();
|
||||
minBufferMs = newMinBufferMs;
|
||||
maxBufferMs = newMaxBufferMs;
|
||||
bufferForPlaybackMs = newBufferForPlaybackMs;
|
||||
bufferForPlaybackAfterRebufferMs = newBufferForPlaybackAfterRebufferMs;
|
||||
initializePlayer();
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
||||
private static final String PROP_PAUSED = "paused";
|
||||
private static final String PROP_MUTED = "muted";
|
||||
private static final String PROP_VOLUME = "volume";
|
||||
private static final String PROP_LOAD_CONTROL = "loadControl";
|
||||
private static final String PROP_LOAD_CONTROL_MIN_BUFFER_MS = "minBufferMs";
|
||||
private static final String PROP_LOAD_CONTROL_MAX_BUFFER_MS = "maxBufferMs";
|
||||
private static final String PROP_LOAD_CONTROL_BUFFER_FOR_PLAYBACK_MS = "bufferForPlaybackMs";
|
||||
private static final String PROP_LOAD_CONTROL_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS = "bufferForPlaybackAfterRebufferMs";
|
||||
private static final String PROP_BUFFER_CONFIG = "bufferConfig";
|
||||
private static final String PROP_BUFFER_CONFIG_MIN_BUFFER_MS = "minBufferMs";
|
||||
private static final String PROP_BUFFER_CONFIG_MAX_BUFFER_MS = "maxBufferMs";
|
||||
private static final String PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_MS = "bufferForPlaybackMs";
|
||||
private static final String PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS = "bufferForPlaybackAfterRebufferMs";
|
||||
private static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval";
|
||||
private static final String PROP_SEEK = "seek";
|
||||
private static final String PROP_RATE = "rate";
|
||||
@ -220,22 +220,22 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
||||
videoView.setUseTextureView(useTextureView);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_LOAD_CONTROL)
|
||||
public void setLoadControl(final ReactExoplayerView videoView, @Nullable ReadableMap loadControl) {
|
||||
@ReactProp(name = PROP_BUFFER_CONFIG )
|
||||
public void setBufferConfig(final ReactExoplayerView videoView, @Nullable ReadableMap bufferConfig) {
|
||||
int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
|
||||
int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS;
|
||||
int bufferForPlaybackMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS;
|
||||
int bufferForPlaybackAfterRebufferMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS;
|
||||
if (loadControl != null) {
|
||||
minBufferMs = loadControl.hasKey(PROP_LOAD_CONTROL_MIN_BUFFER_MS)
|
||||
? loadControl.getInt(PROP_LOAD_CONTROL_MIN_BUFFER_MS) : minBufferMs;
|
||||
maxBufferMs = loadControl.hasKey(PROP_LOAD_CONTROL_MAX_BUFFER_MS)
|
||||
? loadControl.getInt(PROP_LOAD_CONTROL_MAX_BUFFER_MS) : maxBufferMs;
|
||||
bufferForPlaybackMs = loadControl.hasKey(PROP_LOAD_CONTROL_BUFFER_FOR_PLAYBACK_MS)
|
||||
? loadControl.getInt(PROP_LOAD_CONTROL_BUFFER_FOR_PLAYBACK_MS) : bufferForPlaybackMs;
|
||||
bufferForPlaybackAfterRebufferMs = loadControl.hasKey(PROP_LOAD_CONTROL_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS)
|
||||
? loadControl.getInt(PROP_LOAD_CONTROL_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS) : bufferForPlaybackAfterRebufferMs;
|
||||
videoView.setLoadControl(minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs);
|
||||
if (bufferConfig != null) {
|
||||
minBufferMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_MIN_BUFFER_MS)
|
||||
? bufferConfig.getInt(PROP_BUFFER_CONFIG_MIN_BUFFER_MS) : minBufferMs;
|
||||
maxBufferMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_MAX_BUFFER_MS)
|
||||
? bufferConfig.getInt(PROP_BUFFER_CONFIG_MAX_BUFFER_MS) : maxBufferMs;
|
||||
bufferForPlaybackMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_MS)
|
||||
? bufferConfig.getInt(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_MS) : bufferForPlaybackMs;
|
||||
bufferForPlaybackAfterRebufferMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS)
|
||||
? bufferConfig.getInt(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS) : bufferForPlaybackAfterRebufferMs;
|
||||
videoView.setBufferConfig(minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user