From 092ba33e95a3bd5c7229b4d25a09bbba28aab462 Mon Sep 17 00:00:00 2001 From: Bryan van Wijk Date: Tue, 31 Jul 2018 17:23:20 +0200 Subject: [PATCH 1/8] Expose DefaultLoadControl parameters Android --- Video.js | 8 +++- .../brentvatne/exoplayer/ExoPlayerConfig.java | 47 +++++++++++++++++++ .../exoplayer/ReactExoplayerView.java | 27 ++++++++++- .../brentvatne/react/ReactVideoPackage.java | 8 +++- 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java diff --git a/Video.js b/Video.js index f32725f3..71f38723 100644 --- a/Video.js +++ b/Video.js @@ -11,7 +11,13 @@ const styles = StyleSheet.create({ }, }); -export { TextTrackType }; +const { + ExoPlayerConfig +} = NativeModules + +const VideoPlayerConfig = Platform.OS === "android" ? ExoPlayerConfig : undefined; + +export { TextTrackType, VideoPlayerConfig}; export default class Video extends Component { diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java new file mode 100644 index 00000000..90c68d01 --- /dev/null +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java @@ -0,0 +1,47 @@ +package com.brentvatne.exoplayer; + +import android.content.Context; + +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.Promise; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; + + +public class ExoPlayerConfig extends ReactContextBaseJavaModule { + + public ExoPlayerConfig(ReactApplicationContext reactContext) { + super(reactContext); + } + + @Override + public String getName() { + return "ExoPlayerConfig"; + } + + @ReactMethod + public void setMinBufferMs(final int newMinBufferMs, final Promise promise) { + ReactExoplayerView.setMinBufferMs(newMinBufferMs); + promise.resolve(null); + } + + @ReactMethod + public void setMaxBufferMs(final int newMaxBufferMs, final Promise promise) { + ReactExoplayerView.setMaxBufferMs(newMaxBufferMs); + promise.resolve(null); + } + + @ReactMethod + public void setBufferForPlaybackMs(final int newBufferForPlaybackMs, final Promise promise) { + ReactExoplayerView.setBufferForPlaybackMs(newBufferForPlaybackMs); + promise.resolve(null); + } + + @ReactMethod + public void setBufferForPlaybackAfterRebufferMs(final int newBufferForPlaybackAfterRebufferMs, final Promise promise) { + ReactExoplayerView.setBufferForPlaybackAfterRebufferMs(newBufferForPlaybackAfterRebufferMs); + promise.resolve(null); + } +} 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 487da343..c401e3d2 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -58,6 +58,7 @@ import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.upstream.DataSource; +import com.google.android.exoplayer2.upstream.DefaultAllocator; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; @@ -90,6 +91,11 @@ class ReactExoplayerView extends FrameLayout implements DEFAULT_COOKIE_MANAGER.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); } + private static int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS; + private static int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS; + private static int bufferForPlaybackMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS; + private static int bufferForPlaybackAfterRebufferMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS; + private final VideoEventEmitter eventEmitter; private Handler mainHandler; @@ -234,7 +240,9 @@ class ReactExoplayerView extends FrameLayout implements if (player == null) { TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); - player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, new DefaultLoadControl()); + DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE); + DefaultLoadControl defaultLoadControl = new DefaultLoadControl(allocator, minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs, -1, true); + player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, defaultLoadControl); player.addListener(this); player.setMetadataOutput(this); exoPlayerView.setPlayer(player); @@ -931,4 +939,21 @@ class ReactExoplayerView extends FrameLayout implements public void setUseTextureView(boolean useTextureView) { exoPlayerView.setUseTextureView(useTextureView); } + + + public static void setMinBufferMs(int newMinBufferMs) { + minBufferMs = newMinBufferMs; + } + + public static void setMaxBufferMs(int newMaxBufferMs) { + maxBufferMs = newMaxBufferMs; + } + + public static void setBufferForPlaybackMs(int newBufferForPlaybackMs) { + bufferForPlaybackMs = newBufferForPlaybackMs; + } + + public static void setBufferForPlaybackAfterRebufferMs(int newBufferForPlaybackAfterRebufferMs) { + bufferForPlaybackAfterRebufferMs = newBufferForPlaybackAfterRebufferMs; + } } diff --git a/android-exoplayer/src/main/java/com/brentvatne/react/ReactVideoPackage.java b/android-exoplayer/src/main/java/com/brentvatne/react/ReactVideoPackage.java index 286f972c..34ee588b 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/react/ReactVideoPackage.java +++ b/android-exoplayer/src/main/java/com/brentvatne/react/ReactVideoPackage.java @@ -1,12 +1,14 @@ package com.brentvatne.react; import com.brentvatne.exoplayer.ReactExoplayerViewManager; +import com.brentvatne.exoplayer.ExoPlayerConfig; import com.facebook.react.ReactPackage; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -14,7 +16,11 @@ public class ReactVideoPackage implements ReactPackage { @Override public List createNativeModules(ReactApplicationContext reactContext) { - return Collections.emptyList(); + List modules = new ArrayList<>(); + + modules.add(new ExoPlayerConfig(reactContext)); + + return modules; } // Deprecated RN 0.47 From dde27a320e9124278c4d6169d192613480efbb5a Mon Sep 17 00:00:00 2001 From: Bryan van Wijk Date: Wed, 1 Aug 2018 15:58:02 +0200 Subject: [PATCH 2/8] Pass loadControl parameters as video props --- README.md | 25 ++++++++++ Video.js | 14 +++--- .../brentvatne/exoplayer/ExoPlayerConfig.java | 47 ------------------- .../exoplayer/ReactExoplayerView.java | 33 +++++-------- .../exoplayer/ReactExoplayerViewManager.java | 25 ++++++++++ .../brentvatne/react/ReactVideoPackage.java | 8 +--- 6 files changed, 71 insertions(+), 81 deletions(-) delete mode 100644 android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java diff --git a/README.md b/README.md index ed6ffae9..5d2cc600 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ var styles = StyleSheet.create({ * [textTracks](#texttracks) * [useTextureView](#usetextureview) * [volume](#volume) +* [loadControl](#loadcontrol) ### Event props * [onAudioBecomingNoisy](#onaudiobecomingnoisy) @@ -479,6 +480,30 @@ Adjust the volume. Platforms: all +#### loadControl +Adjust the load control parameters: minBufferMs, maxBufferMs, bufferForPlaybackMs and playbackAfterRebufferMs. + +``` +loadControl={{ + minBufferMs: number, + maxBufferMs: number, + bufferForPlaybackMs: number, + bufferForPlaybackAfterRebufferMs: number, +}} +``` + +Example with default values: +``` +loadControl={{ + minBufferMs: 15000, + maxBufferMs: 50000, + bufferForPlaybackMs: 2500, + bufferForPlaybackAfterRebufferMs: 5000, +}} +``` + +Platforms: AndroidExoplayer + ### Event props #### onAudioBecomingNoisy diff --git a/Video.js b/Video.js index 71f38723..14401078 100644 --- a/Video.js +++ b/Video.js @@ -11,13 +11,7 @@ const styles = StyleSheet.create({ }, }); -const { - ExoPlayerConfig -} = NativeModules - -const VideoPlayerConfig = Platform.OS === "android" ? ExoPlayerConfig : undefined; - -export { TextTrackType, VideoPlayerConfig}; +export { TextTrackType }; export default class Video extends Component { @@ -351,6 +345,12 @@ Video.propTypes = { paused: PropTypes.bool, muted: PropTypes.bool, volume: PropTypes.number, + loadControl: PropTypes.shape({ + minBufferMs: PropTypes.number, + maxBufferMs: PropTypes.number, + bufferForPlaybackMs: PropTypes.number, + bufferForPlaybackAfterRebufferMs: PropTypes.number, + }), stereoPan: PropTypes.number, rate: PropTypes.number, playInBackground: PropTypes.bool, diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java deleted file mode 100644 index 90c68d01..00000000 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.brentvatne.exoplayer; - -import android.content.Context; - -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.bridge.Promise; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactMethod; - - -public class ExoPlayerConfig extends ReactContextBaseJavaModule { - - public ExoPlayerConfig(ReactApplicationContext reactContext) { - super(reactContext); - } - - @Override - public String getName() { - return "ExoPlayerConfig"; - } - - @ReactMethod - public void setMinBufferMs(final int newMinBufferMs, final Promise promise) { - ReactExoplayerView.setMinBufferMs(newMinBufferMs); - promise.resolve(null); - } - - @ReactMethod - public void setMaxBufferMs(final int newMaxBufferMs, final Promise promise) { - ReactExoplayerView.setMaxBufferMs(newMaxBufferMs); - promise.resolve(null); - } - - @ReactMethod - public void setBufferForPlaybackMs(final int newBufferForPlaybackMs, final Promise promise) { - ReactExoplayerView.setBufferForPlaybackMs(newBufferForPlaybackMs); - promise.resolve(null); - } - - @ReactMethod - public void setBufferForPlaybackAfterRebufferMs(final int newBufferForPlaybackAfterRebufferMs, final Promise promise) { - ReactExoplayerView.setBufferForPlaybackAfterRebufferMs(newBufferForPlaybackAfterRebufferMs); - promise.resolve(null); - } -} 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 c401e3d2..878ed261 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -91,11 +91,6 @@ class ReactExoplayerView extends FrameLayout implements DEFAULT_COOKIE_MANAGER.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); } - private static int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS; - private static int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS; - private static int bufferForPlaybackMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS; - private static int bufferForPlaybackAfterRebufferMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS; - private final VideoEventEmitter eventEmitter; private Handler mainHandler; @@ -115,6 +110,11 @@ class ReactExoplayerView extends FrameLayout implements private boolean isBuffering; private float rate = 1f; + private int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS; + private int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS; + private int bufferForPlaybackMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS; + private int bufferForPlaybackAfterRebufferMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS; + // Props from React private Uri srcUri; private String extension; @@ -940,20 +940,13 @@ class ReactExoplayerView extends FrameLayout implements exoPlayerView.setUseTextureView(useTextureView); } - - public static void setMinBufferMs(int newMinBufferMs) { - minBufferMs = newMinBufferMs; - } - - public static void setMaxBufferMs(int newMaxBufferMs) { - maxBufferMs = newMaxBufferMs; - } - - public static void setBufferForPlaybackMs(int newBufferForPlaybackMs) { - bufferForPlaybackMs = newBufferForPlaybackMs; - } - - public static void setBufferForPlaybackAfterRebufferMs(int newBufferForPlaybackAfterRebufferMs) { - bufferForPlaybackAfterRebufferMs = newBufferForPlaybackAfterRebufferMs; + 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; + initializePlayer(); } } 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 fbc8a9ad..9611a960 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -11,6 +11,7 @@ import com.facebook.react.common.MapBuilder; import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.annotations.ReactProp; +import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.upstream.RawResourceDataSource; import java.util.HashMap; @@ -38,6 +39,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager createNativeModules(ReactApplicationContext reactContext) { - List modules = new ArrayList<>(); - - modules.add(new ExoPlayerConfig(reactContext)); - - return modules; + return Collections.emptyList(); } // Deprecated RN 0.47 From f46a00c4d43adbbc5d4f3d6df12d1a38f504d8ff Mon Sep 17 00:00:00 2001 From: Bryan van Wijk Date: Wed, 1 Aug 2018 16:07:25 +0200 Subject: [PATCH 3/8] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 5d2cc600..3b721e58 100644 --- a/README.md +++ b/README.md @@ -483,6 +483,13 @@ Platforms: all #### loadControl Adjust the load control parameters: minBufferMs, maxBufferMs, bufferForPlaybackMs and playbackAfterRebufferMs. +Property | Description +--- | --- +minBufferMs | The default minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. +maxBufferMs | The default maximum duration of media that the player will attempt to buffer, in milliseconds. +bufferForPlaybackMs | The default duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. +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={{ minBufferMs: number, From cd75e72180b6424f5c0dd2b4fbdbd9dc7773ce94 Mon Sep 17 00:00:00 2001 From: Bryan van Wijk Date: Thu, 2 Aug 2018 09:20:08 +0200 Subject: [PATCH 4/8] Rename to bufferConfig and use stopPlayback --- README.md | 9 ++--- Video.js | 2 +- .../exoplayer/ReactExoplayerView.java | 13 ++++--- .../exoplayer/ReactExoplayerViewManager.java | 34 +++++++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 3b721e58..f9c49879 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/Video.js b/Video.js index 14401078..5c6cd1d3 100644 --- a/Video.js +++ b/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, 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 878ed261..60f74416 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -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(); } } 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 9611a960..88839432 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -39,11 +39,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Thu, 2 Aug 2018 09:23:00 +0200 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9c49879..68d8c3a4 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ var styles = StyleSheet.create({ * [textTracks](#texttracks) * [useTextureView](#usetextureview) * [volume](#volume) -* [loadControl](#loadcontrol) +* [bufferConfig](#bufferconfig) ### Event props * [onAudioBecomingNoisy](#onaudiobecomingnoisy) From 9ff16ed550e9ad2572df3a50a068b98a70493bcc Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Fri, 3 Aug 2018 14:55:46 -0700 Subject: [PATCH 6/8] Tidy up bufferConfig docs --- README.md | 58 ++++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 68d8c3a4..947f4f2a 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,7 @@ var styles = StyleSheet.create({ ### Configurable props * [allowsExternalPlayback](#allowsexternalplayback) * [audioOnly](#audioonly) +* [bufferConfig](#bufferconfig) * [ignoreSilentSwitch](#ignoresilentswitch) * [muted](#muted) * [paused](#paused) @@ -229,7 +230,6 @@ var styles = StyleSheet.create({ * [textTracks](#texttracks) * [useTextureView](#usetextureview) * [volume](#volume) -* [bufferConfig](#bufferconfig) ### Event props * [onAudioBecomingNoisy](#onaudiobecomingnoisy) @@ -265,6 +265,30 @@ For this to work, the poster prop must be set. Platforms: all +#### bufferConfig +Adjust the buffer settings. This prop takes an object with one or more of the properties listed below. + +This prop can only be set when you are setting a new source, changing it after the media is loaded will cause it to restart. + +Property | Type | Description +--- | --- | --- +minBufferMs | number | The default minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. +maxBufferMs | number | The default maximum duration of media that the player will attempt to buffer, in milliseconds. +bufferForPlaybackMs | number | The default duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. +playbackAfterRebufferMs | number | 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. + +Example with default values: +``` +bufferConfig={{ + minBufferMs: 15000, + maxBufferMs: 50000, + bufferForPlaybackMs: 2500, + bufferForPlaybackAfterRebufferMs: 5000 +}} +``` + +Platforms: Android ExoPlayer + #### ignoreSilentSwitch Controls the iOS silent switch behavior * **"inherit" (default)** - Use the default AVPlayer behavior @@ -480,38 +504,6 @@ Adjust the volume. Platforms: all -#### 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 ---- | --- -minBufferMs | The default minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. -maxBufferMs | The default maximum duration of media that the player will attempt to buffer, in milliseconds. -bufferForPlaybackMs | The default duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. -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. - -``` -bufferConfig={{ - minBufferMs: number, - maxBufferMs: number, - bufferForPlaybackMs: number, - bufferForPlaybackAfterRebufferMs: number, -}} -``` - -Example with default values: -``` -bufferConfig={{ - minBufferMs: 15000, - maxBufferMs: 50000, - bufferForPlaybackMs: 2500, - bufferForPlaybackAfterRebufferMs: 5000, -}} -``` - -Platforms: AndroidExoplayer - ### Event props #### onAudioBecomingNoisy From 725497e149cbe2308a3848e9af4dbbbefe9cf210 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Fri, 3 Aug 2018 15:54:18 -0700 Subject: [PATCH 7/8] Don't set isPaused when releasing the player I'm guessing this was a bug as it doesn't make sense that we would set paused to true if the video is playing, and not paused if it wasn't. I believe this is a safe change since we only release the player when the app is closing or we detach (which is going away shortly). We need this since we release the player in order to apply new bufferConfig settings. --- .../main/java/com/brentvatne/exoplayer/ReactExoplayerView.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 60f74416..9ef099cf 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -328,7 +328,6 @@ class ReactExoplayerView extends FrameLayout implements private void releasePlayer() { if (player != null) { - isPaused = player.getPlayWhenReady(); updateResumePosition(); player.release(); player.setMetadataOutput(null); @@ -941,11 +940,11 @@ class ReactExoplayerView extends FrameLayout implements } public void setBufferConfig(int newMinBufferMs, int newMaxBufferMs, int newBufferForPlaybackMs, int newBufferForPlaybackAfterRebufferMs) { - stopPlayback(); minBufferMs = newMinBufferMs; maxBufferMs = newMaxBufferMs; bufferForPlaybackMs = newBufferForPlaybackMs; bufferForPlaybackAfterRebufferMs = newBufferForPlaybackAfterRebufferMs; + releasePlayer(); initializePlayer(); } } From a60a1277b7849edbb0f2424d6c4629711410e52e Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Fri, 3 Aug 2018 15:54:55 -0700 Subject: [PATCH 8/8] Remove extra space --- .../com/brentvatne/exoplayer/ReactExoplayerViewManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 88839432..9ead70ce 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -220,7 +220,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager