Commit cd75e721 authored by Bryan van Wijk's avatar Bryan van Wijk
Browse files

Rename to bufferConfig and use stopPlayback

parent f46a00c4
Loading
Loading
Loading
Loading
+5 −4
Changes for README.md: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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,
+1 −1
Changes for Video.js: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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,
+6 −7
Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java: 6 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -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();
    }
}
+17 −17
Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java: 17 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -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);
        }
    }