summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-04-12 19:49:02 -0700
committerJames Dong <jdong@google.com>2012-04-17 18:31:20 -0700
commitc4c0284e45e1b69a03309cd55f937bcc638c0bec (patch)
treeaab2165dd862f2c37f6277e129487afcac4cc413 /media
parentfbf7e1f343b4d61c48187adb123a4308e809a92d (diff)
downloadframeworks_base-c4c0284e45e1b69a03309cd55f937bcc638c0bec.zip
frameworks_base-c4c0284e45e1b69a03309cd55f937bcc638c0bec.tar.gz
frameworks_base-c4c0284e45e1b69a03309cd55f937bcc638c0bec.tar.bz2
AddExternalSource(String path) needs to turn the path to fd if it is a file
o related-to-bug: 5542712 Change-Id: Iea32012996ca9de4c86f144de916df64fcab3c52
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaPlayer.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index dd01db6..545752c 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -1619,18 +1619,22 @@ public class MediaPlayer
// FIXME: define error codes and throws exceptions according to the error codes.
// (IllegalStateException, IOException).
public void addExternalSource(String path, String mimeType)
- throws IllegalArgumentException {
+ throws IOException, IllegalArgumentException {
if (!availableMimeTypeForExternalSource(mimeType)) {
- throw new IllegalArgumentException("Illegal mimeType for external source: " + mimeType);
+ final String msg = "Illegal mimeType for external source: " + mimeType;
+ throw new IllegalArgumentException(msg);
}
- Parcel request = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- request.writeInterfaceToken(IMEDIA_PLAYER);
- request.writeInt(INVOKE_ID_ADD_EXTERNAL_SOURCE);
- request.writeString(path);
- request.writeString(mimeType);
- invoke(request, reply);
+ File file = new File(path);
+ if (file.exists()) {
+ FileInputStream is = new FileInputStream(file);
+ FileDescriptor fd = is.getFD();
+ addExternalSource(fd, mimeType);
+ is.close();
+ } else {
+ // We do not support the case where the path is not a file.
+ throw new IOException(path);
+ }
}
/**
@@ -1671,8 +1675,6 @@ public class MediaPlayer
fd.close();
}
}
-
- // TODO: try server side.
}
/* Do not change these values without updating their counterparts
@@ -1732,6 +1734,7 @@ public class MediaPlayer
if (!availableMimeTypeForExternalSource(mimeType)) {
throw new IllegalArgumentException("Illegal mimeType for external source: " + mimeType);
}
+
Parcel request = Parcel.obtain();
Parcel reply = Parcel.obtain();
request.writeInterfaceToken(IMEDIA_PLAYER);