Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ Video.propTypes = {
reportBandwidth: PropTypes.bool,
disableFocus: PropTypes.bool,
controls: PropTypes.bool,
httpEngine: PropTypes.string,
audioOnly: PropTypes.bool,
currentTime: PropTypes.number,
fullscreenAutorotate: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import okhttp3.JavaNetCookieJar;
import okhttp3.OkHttpClient;
import java.util.HashMap;
import java.util.Map;

public class DataSourceUtil {
Expand All @@ -24,6 +25,7 @@ private DataSourceUtil() {
private static DataSource.Factory defaultDataSourceFactory = null;
private static HttpDataSource.Factory defaultHttpDataSourceFactory = null;
private static String userAgent = null;
private static final Map<String, DataSource.Factory> namedDataSourceFactories = new HashMap<>();

public static void setUserAgent(String userAgent) {
DataSourceUtil.userAgent = userAgent;
Expand Down Expand Up @@ -70,6 +72,15 @@ public static void setDefaultHttpDataSourceFactory(HttpDataSource.Factory factor
DataSourceUtil.defaultHttpDataSourceFactory = factory;
}

public static void registerDataSourceFactory(String name, DataSource.Factory factory) {
namedDataSourceFactories.put(name, factory);
}

public static DataSource.Factory getNamedDataSourceFactory(String name) {
DataSource.Factory factory = namedDataSourceFactories.get(name);
return factory != null ? factory : defaultDataSourceFactory;
}

private static DataSource.Factory buildRawDataSourceFactory(ReactContext context) {
return new RawResourceDataSourceFactory(context.getApplicationContext());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class ReactExoplayerView extends FrameLayout implements
private float mProgressUpdateInterval = 250.0f;
private boolean playInBackground = false;
private Map<String, String> requestHeaders;
private String httpEngine = null;
private boolean mReportBandwidth = false;
private UUID drmUUID = null;
private String drmLicenseUrl = null;
Expand Down Expand Up @@ -647,6 +648,12 @@ private void clearResumePosition() {
* @return A new DataSource factory.
*/
private DataSource.Factory buildDataSourceFactory(boolean useBandwidthMeter) {
if (httpEngine != null && !httpEngine.isEmpty() && !httpEngine.equals("default")) {
DataSource.Factory namedFactory = DataSourceUtil.getNamedDataSourceFactory(httpEngine);
if (namedFactory != null) {
return namedFactory;
}
}
return DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext,
useBandwidthMeter ? bandwidthMeter : null, requestHeaders);
}
Expand Down Expand Up @@ -1038,9 +1045,7 @@ public void setSrc(final Uri uri, final String extension, Map<String, String> he
this.srcUri = uri;
this.extension = extension;
this.requestHeaders = headers;
this.mediaDataSourceFactory =
DataSourceUtil.getDefaultDataSourceFactory(this.themedReactContext, bandwidthMeter,
this.requestHeaders);
this.mediaDataSourceFactory = buildDataSourceFactory(true);

if (!isSourceEqual) {
reloadSource();
Expand Down Expand Up @@ -1312,6 +1317,13 @@ public void setDisableFocus(boolean disableFocus) {
this.disableFocus = disableFocus;
}

public void setHttpEngine(String httpEngine) {
this.httpEngine = httpEngine;
if (srcUri != null) {
this.mediaDataSourceFactory = buildDataSourceFactory(true);
}
}

public void setFullscreen(boolean fullscreen) {
if (fullscreen == isFullscreen) {
return; // Avoid generating events when nothing is changing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_SELECTED_VIDEO_TRACK_VALUE = "value";
private static final String PROP_HIDE_SHUTTER_VIEW = "hideShutterView";
private static final String PROP_CONTROLS = "controls";
private static final String PROP_HTTP_ENGINE = "httpEngine";

private ReactExoplayerConfig config;

Expand Down Expand Up @@ -323,6 +324,11 @@ public void setControls(final ReactExoplayerView videoView, final boolean contro
videoView.setControls(controls);
}

@ReactProp(name = PROP_HTTP_ENGINE)
public void setHttpEngine(final ReactExoplayerView videoView, @Nullable final String httpEngine) {
videoView.setHttpEngine(httpEngine);
}

@ReactProp(name = PROP_BUFFER_CONFIG)
public void setBufferConfig(final ReactExoplayerView videoView, @Nullable ReadableMap bufferConfig) {
int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
Expand Down