diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 2fa0c931e84cf..7c3b4fc1e1346 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -1049,8 +1049,17 @@ public class MediaPlayer implements SubtitleController.Listener private void setDataSource(String path, String[] keys, String[] values) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException { final Uri uri = Uri.parse(path); - if ("file".equals(uri.getScheme())) { + final String scheme = uri.getScheme(); + if ("file".equals(scheme)) { path = uri.getPath(); + } else if (scheme != null) { + // handle non-file sources + nativeSetDataSource( + MediaHTTPService.createHttpServiceBinderIfNecessary(path), + path, + keys, + values); + return; } final File file = new File(path); @@ -1060,20 +1069,10 @@ public class MediaPlayer implements SubtitleController.Listener setDataSource(fd); is.close(); } else { - _setDataSource(path, keys, values); + throw new IOException("setDataSource failed."); } } - private void _setDataSource( - String path, String[] keys, String[] values) - throws IOException, IllegalArgumentException, SecurityException, IllegalStateException { - nativeSetDataSource( - MediaHTTPService.createHttpServiceBinderIfNecessary(path), - path, - keys, - values); - } - private native void nativeSetDataSource( IBinder httpServiceBinder, String path, String[] keys, String[] values) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;