Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cookiePolicy prop for ExoPlayer #10

Merged
merged 2 commits into from
Jul 14, 2020
Merged
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
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,6 @@ class ReactExoplayerView extends FrameLayout implements

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

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

Expand Down Expand Up @@ -202,6 +202,7 @@ private void createViews() {
clearResumePosition();
mediaDataSourceFactory = buildDataSourceFactory(true);
if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
DEFAULT_COOKIE_MANAGER.setCookiePolicy(this.getCookiePolicy());
CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
}

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,12 @@ public void setReportBandwidth(boolean reportBandwidth) {
mReportBandwidth = reportBandwidth;
}

public void setCookiePolicy(String cookiePolicy) {
mCookiePolicy = cookiePolicy;
DEFAULT_COOKIE_MANAGER.setCookiePolicy(this.getCookiePolicy());
CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
}

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)
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