diff --git a/media/base/android/java/src/org/chromium/media/MediaPlayerBridge.java b/media/base/android/java/src/org/chromium/media/MediaPlayerBridge.java index 830cc20049210..0be89faf91d19 100644 --- a/media/base/android/java/src/org/chromium/media/MediaPlayerBridge.java +++ b/media/base/android/java/src/org/chromium/media/MediaPlayerBridge.java @@ -35,12 +35,18 @@ */ @JNINamespace("media") public class MediaPlayerBridge { - + /** + * Give the host application a chance to take over MeidaPlayer. + */ public static class ResourceLoadingFilter { public boolean shouldOverrideResourceLoading( MediaPlayer mediaPlayer, Context context, Uri uri) { return false; } + + public MediaPlayer getExternalMediaPlayer() { + return null; + } } private static ResourceLoadingFilter sResourceLoadFilter = null; @@ -80,7 +86,8 @@ protected void destroy() { protected MediaPlayer getLocalPlayer() { if (mPlayer == null) { - mPlayer = new MediaPlayer(); + mPlayer = sResourceLoadFilter.getExternalMediaPlayer(); + if (mPlayer == null) mPlayer = new MediaPlayer(); } return mPlayer; } @@ -202,9 +209,9 @@ protected boolean setDataSource( headersMap.put("allow-cross-domain-redirect", "false"); } try { - if (sResourceLoadFilter != null && - sResourceLoadFilter.shouldOverrideResourceLoading( - getLocalPlayer(), context, uri)) { + if (sResourceLoadFilter != null + && sResourceLoadFilter.shouldOverrideResourceLoading( + getLocalPlayer(), context, uri)) { return true; } getLocalPlayer().setDataSource(context, uri, headersMap);