|  | 
| 35 | 35 | */ | 
| 36 | 36 | @JNINamespace("media") | 
| 37 | 37 | public class MediaPlayerBridge { | 
| 38 |  | - | 
|  | 38 | +    /** | 
|  | 39 | +    * Give the host application a chance to take over MeidaPlayer. | 
|  | 40 | +    */ | 
| 39 | 41 |     public static class ResourceLoadingFilter { | 
| 40 | 42 |         public boolean shouldOverrideResourceLoading( | 
| 41 | 43 |                 MediaPlayer mediaPlayer, Context context, Uri uri) { | 
| 42 | 44 |             return false; | 
| 43 | 45 |         } | 
|  | 46 | + | 
|  | 47 | +        public MediaPlayer getExternalMediaPlayer() { | 
|  | 48 | +            return null; | 
|  | 49 | +        } | 
| 44 | 50 |     } | 
| 45 | 51 | 
 | 
| 46 | 52 |     private static ResourceLoadingFilter sResourceLoadFilter = null; | 
| @@ -80,7 +86,8 @@ protected void destroy() { | 
| 80 | 86 | 
 | 
| 81 | 87 |     protected MediaPlayer getLocalPlayer() { | 
| 82 | 88 |         if (mPlayer == null) { | 
| 83 |  | -            mPlayer = new MediaPlayer(); | 
|  | 89 | +            mPlayer = sResourceLoadFilter.getExternalMediaPlayer(); | 
|  | 90 | +            if (mPlayer == null) mPlayer = new MediaPlayer(); | 
| 84 | 91 |         } | 
| 85 | 92 |         return mPlayer; | 
| 86 | 93 |     } | 
| @@ -202,9 +209,9 @@ protected boolean setDataSource( | 
| 202 | 209 |             headersMap.put("allow-cross-domain-redirect", "false"); | 
| 203 | 210 |         } | 
| 204 | 211 |         try { | 
| 205 |  | -            if (sResourceLoadFilter != null && | 
| 206 |  | -                    sResourceLoadFilter.shouldOverrideResourceLoading( | 
| 207 |  | -                            getLocalPlayer(), context, uri)) { | 
|  | 212 | +            if (sResourceLoadFilter != null | 
|  | 213 | +                    && sResourceLoadFilter.shouldOverrideResourceLoading( | 
|  | 214 | +                               getLocalPlayer(), context, uri)) { | 
| 208 | 215 |                 return true; | 
| 209 | 216 |             } | 
| 210 | 217 |             getLocalPlayer().setDataSource(context, uri, headersMap); | 
|  | 
0 commit comments