Skip to content

Commit

Permalink
added cookiePolicy prop for ExoPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
anubansal92 committed Jul 13, 2020
1 parent 34b7edf commit 2a3d4ba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ var styles = StyleSheet.create({
* [hideShutterView](#hideshutterview)
* [id](#id)
* [ignoreSilentSwitch](#ignoresilentswitch)
* [cookiePolicy](#cookiepolicy)
* [maxBitRate](#maxbitrate)
* [minLoadRetryCount](#minLoadRetryCount)
* [muted](#muted)
Expand Down Expand Up @@ -521,6 +522,14 @@ Controls the iOS silent switch behavior

Platforms: iOS

#### cookiePolicy
Changes the android cookie policy
* **"original" (default)** - Sets the CookiePolicy as ACCEPT_ORIGINAL_SERVER
* **"all"** - Sets the CookiePolicy as ACCEPT_ALL
* **"none"** - Sets the CookiePolicy as ACCEPT_NONE

Platforms: Android ExoPlayer

#### maxBitRate
Sets the desired limit, in bits per second, of network bandwidth consumption when multiple video streams are available for a playlist.

Expand Down
1 change: 1 addition & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ Video.propTypes = {
preferredForwardBufferDuration: PropTypes.number,
playWhenInactive: PropTypes.bool,
ignoreSilentSwitch: PropTypes.oneOf(['ignore', 'obey']),
cookiePolicy: PropTypes.oneOf(['original', 'all', 'none']),
reportBandwidth: PropTypes.bool,
disableFocus: PropTypes.bool,
controls: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ReactExoplayerView extends FrameLayout implements

static {
DEFAULT_COOKIE_MANAGER = new CookieManager();
DEFAULT_COOKIE_MANAGER.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
DEFAULT_COOKIE_MANAGER.setCookiePolicy(this.getCookiePolicy());
}

private final VideoEventEmitter eventEmitter;
Expand Down Expand Up @@ -139,6 +139,7 @@ class ReactExoplayerView extends FrameLayout implements
private boolean playInBackground = false;
private Map<String, String> requestHeaders;
private boolean mReportBandwidth = false;
private String mCookiePolicy = "original";
private boolean controls;
// \ End props

Expand Down Expand Up @@ -419,6 +420,18 @@ public void run() {
}, 1);
}

private CookiePolicy getCookiePolicy() {
switch (mCookiePolicy) {
case "all":
return CookiePolicy.ACCEPT_ALL;
case "none":
return CookiePolicy.ACCEPT_NONE;
case "original":
default:
return CookiePolicy.ACCEPT_ORIGINAL_SERVER;
}
}

private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
: uri.getLastPathSegment());
Expand Down Expand Up @@ -931,6 +944,10 @@ public void setReportBandwidth(boolean reportBandwidth) {
mReportBandwidth = reportBandwidth;
}

public void setCookiePolicy(String cookiePolicy) {
mCookiePolicy = cookiePolicy;
}

public void setRawSrc(final Uri uri, final String extension) {
if (uri != null) {
boolean isOriginalSourceNull = srcUri == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
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_REPORT_BANDWIDTH = "reportBandwidth";
private static final String PROP_COOKIE_POLICY = "cookiePolicy";
private static final String PROP_SEEK = "seek";
private static final String PROP_RATE = "rate";
private static final String PROP_MIN_LOAD_RETRY_COUNT = "minLoadRetryCount";
Expand Down Expand Up @@ -223,6 +224,11 @@ public void setReportBandwidth(final ReactExoplayerView videoView, final boolean
videoView.setReportBandwidth(reportBandwidth);
}

@ReactProp(name = PROP_COOKIE_POLICY, defaultString = "original")
public void setCookiePolicy(final ReactExoplayerView videoView, final String cookiePolicy) {
videoView.setCookiePolicy(cookiePolicy);
}

@ReactProp(name = PROP_SEEK)
public void setSeek(final ReactExoplayerView videoView, final float seek) {
videoView.seekTo(Math.round(seek * 1000f));
Expand Down

0 comments on commit 2a3d4ba

Please sign in to comment.