media.MediaPlayer: don't check file-existence for URI-s with scheme
setDataSource can be called with URI-s as well as with file paths. Check file-existence only for file:// URI-s as well as URI-s without scheme (which are assumed to be paths). Bug: 17109022 Change-Id: I70f16a4f614dcef0b47fa264cf708473036cef4e
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user