Loading README.md +25 −0 Changes for README.md: 25 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ var styles = StyleSheet.create({ * [textTracks](#texttracks) * [useTextureView](#usetextureview) * [volume](#volume) * [loadControl](#loadcontrol) ### Event props * [onAudioBecomingNoisy](#onaudiobecomingnoisy) Loading Loading @@ -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 Loading Video.js +7 −7 Changes for Video.js: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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, Loading android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.javadeleted 100644 → 0 +0 −47 Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java: 0 added lines, 47 removed lines. Original line number Diff line number Diff line 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); } } android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +13 −20 Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java: 13 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } } android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +25 −0 Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java: 25 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -38,6 +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_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval"; private static final String PROP_SEEK = "seek"; private static final String PROP_RATE = "rate"; Loading Loading @@ -214,6 +220,25 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi videoView.setUseTextureView(useTextureView); } @ReactProp(name = PROP_LOAD_CONTROL) public void setLoadControl(final ReactExoplayerView videoView, @Nullable ReadableMap loadControl) { 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); } } private boolean startsWithValidScheme(String uriString) { return uriString.startsWith("http://") || uriString.startsWith("https://") Loading Loading
README.md +25 −0 Changes for README.md: 25 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ var styles = StyleSheet.create({ * [textTracks](#texttracks) * [useTextureView](#usetextureview) * [volume](#volume) * [loadControl](#loadcontrol) ### Event props * [onAudioBecomingNoisy](#onaudiobecomingnoisy) Loading Loading @@ -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 Loading
Video.js +7 −7 Changes for Video.js: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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, Loading
android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.javadeleted 100644 → 0 +0 −47 Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerConfig.java: 0 added lines, 47 removed lines. Original line number Diff line number Diff line 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); } }
android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +13 −20 Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java: 13 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } }
android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +25 −0 Changes for android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java: 25 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -38,6 +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_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval"; private static final String PROP_SEEK = "seek"; private static final String PROP_RATE = "rate"; Loading Loading @@ -214,6 +220,25 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi videoView.setUseTextureView(useTextureView); } @ReactProp(name = PROP_LOAD_CONTROL) public void setLoadControl(final ReactExoplayerView videoView, @Nullable ReadableMap loadControl) { 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); } } private boolean startsWithValidScheme(String uriString) { return uriString.startsWith("http://") || uriString.startsWith("https://") Loading