Merge pull request #211 from stephenmudra/android-cookies
Adding Cookie Support for Android Devices
This commit is contained in:
commit
ad29d3ea9f
@ -3,6 +3,10 @@ package com.brentvatne.react;
|
|||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
import com.facebook.react.bridge.Arguments;
|
import com.facebook.react.bridge.Arguments;
|
||||||
import com.facebook.react.bridge.WritableMap;
|
import com.facebook.react.bridge.WritableMap;
|
||||||
import com.facebook.react.uimanager.ThemedReactContext;
|
import com.facebook.react.uimanager.ThemedReactContext;
|
||||||
@ -122,7 +126,24 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
|
|||||||
mMediaPlayer.reset();
|
mMediaPlayer.reset();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isNetwork || isAsset) {
|
if (isNetwork) {
|
||||||
|
// Use the shared CookieManager to access the cookies
|
||||||
|
// set by WebViews inside the same app
|
||||||
|
CookieManager cookieManager = CookieManager.getInstance();
|
||||||
|
|
||||||
|
Uri parsedUrl = Uri.parse(uriString);
|
||||||
|
Uri.Builder builtUrl = parsedUrl.buildUpon();
|
||||||
|
|
||||||
|
String cookie = cookieManager.getCookie(builtUrl.build().toString());
|
||||||
|
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
|
||||||
|
if (cookie != null) {
|
||||||
|
headers.put("Cookie", cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
setDataSource(mThemedReactContext, parsedUrl, headers);
|
||||||
|
} else if (isAsset) {
|
||||||
setDataSource(uriString);
|
setDataSource(uriString);
|
||||||
} else {
|
} else {
|
||||||
setRawData(mThemedReactContext.getResources().getIdentifier(
|
setRawData(mThemedReactContext.getResources().getIdentifier(
|
||||||
|
Loading…
Reference in New Issue
Block a user