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

Commit 8fcaeac

Browse files
committed
[Android] Support third part media player on Crosswalk
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
1 parent 7e0c695 commit 8fcaeac

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: media/base/android/java/src/org/chromium/media/MediaPlayerBridge.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@
3535
*/
3636
@JNINamespace("media")
3737
public class MediaPlayerBridge {
38-
38+
/**
39+
* Give the host application a chance to take over MeidaPlayer.
40+
*/
3941
public static class ResourceLoadingFilter {
4042
public boolean shouldOverrideResourceLoading(
4143
MediaPlayer mediaPlayer, Context context, Uri uri) {
4244
return false;
4345
}
46+
47+
public MediaPlayer getExternalMediaPlayer() {
48+
return null;
49+
}
4450
}
4551

4652
private static ResourceLoadingFilter sResourceLoadFilter = null;
@@ -80,7 +86,8 @@ protected void destroy() {
8086

8187
protected MediaPlayer getLocalPlayer() {
8288
if (mPlayer == null) {
83-
mPlayer = new MediaPlayer();
89+
mPlayer = sResourceLoadFilter.getExternalMediaPlayer();
90+
if (mPlayer == null) mPlayer = new MediaPlayer();
8491
}
8592
return mPlayer;
8693
}
@@ -202,9 +209,9 @@ protected boolean setDataSource(
202209
headersMap.put("allow-cross-domain-redirect", "false");
203210
}
204211
try {
205-
if (sResourceLoadFilter != null &&
206-
sResourceLoadFilter.shouldOverrideResourceLoading(
207-
getLocalPlayer(), context, uri)) {
212+
if (sResourceLoadFilter != null
213+
&& sResourceLoadFilter.shouldOverrideResourceLoading(
214+
getLocalPlayer(), context, uri)) {
208215
return true;
209216
}
210217
getLocalPlayer().setDataSource(context, uri, headersMap);

0 commit comments

Comments
 (0)