Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Android] Support third part media player on Crosswalk
Browse files Browse the repository at this point in the history
A requirement from an important customer who want to forward web resources with proxy
on Crosswalk, but android system MediaPlayer can't set a proxy with a standard API.
The ExoMediaPlayer is playing videos and music is a popular activity on Android devices,
and it can be configured with proxy.
https://developer.android.com/guide/topics/media/exoplayer.html

BUG=XWALK-6770
  • Loading branch information
fujunwei committed Aug 31, 2016
1 parent 31340fd commit 1dcd337
Show file tree
Hide file tree
Showing 6 changed files with 636 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public XWalkContent(Context context, String animatable, XWalkViewInternal xwView
mGeolocationPermissions = new XWalkGeolocationPermissions(sharedPreferences);

MediaPlayerBridge.setResourceLoadingFilter(
new XWalkMediaPlayerResourceLoadingFilter());
new XWalkMediaPlayerResourceLoadingFilter(mContentsClientBridge));

setNativeContent(nativeInit(), animatable);

Expand Down Expand Up @@ -391,6 +391,11 @@ public void setXWalkWebChromeClient(XWalkWebChromeClient client) {
mContentsClientBridge.setXWalkWebChromeClient(client);
}

public void setXWalkMediaPlayer(XWalkMediaPlayerInternal mediaPlayer) {
if (mNativeContent == 0) return;
mContentsClientBridge.setXWalkMediaPlayer(mediaPlayer);
}

public XWalkWebChromeClient getXWalkWebChromeClient() {
if (mNativeContent == 0) return null;
return mContentsClientBridge.getXWalkWebChromeClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class XWalkContentsClientBridge extends XWalkContentsClient
private XWalkNavigationHandler mNavigationHandler;
private XWalkNotificationService mNotificationService;
private Handler mUiThreadHandler;
private XWalkMediaPlayerInternal mXWalkMediaPlayerInternal;

/** State recording variables */
// For fullscreen state.
Expand Down Expand Up @@ -163,6 +164,13 @@ public void setResourceClient(XWalkResourceClientInternal client) {
mXWalkResourceClient = new XWalkResourceClientInternal(mXWalkView);
}

public void setXWalkMediaPlayer(XWalkMediaPlayerInternal mediaPlayer) {
mXWalkMediaPlayerInternal = mediaPlayer;
}

public XWalkMediaPlayerInternal getExternalMediaPlayer() {
return mXWalkMediaPlayerInternal;
}

public void setXWalkWebChromeClient(XWalkWebChromeClient client) {
// If it's null, use Crosswalk implementation.
Expand Down
Loading

0 comments on commit 1dcd337

Please sign in to comment.