@@ -1619,18 +1619,22 @@ private boolean availableMimeTypeForExternalSource(String mimeType) {
16191619 // FIXME: define error codes and throws exceptions according to the error codes.
16201620 // (IllegalStateException, IOException).
16211621 public void addExternalSource (String path , String mimeType )
1622- throws IllegalArgumentException {
1622+ throws IOException , IllegalArgumentException {
16231623 if (!availableMimeTypeForExternalSource (mimeType )) {
1624- throw new IllegalArgumentException ("Illegal mimeType for external source: " + mimeType );
1624+ final String msg = "Illegal mimeType for external source: " + mimeType ;
1625+ throw new IllegalArgumentException (msg );
16251626 }
16261627
1627- Parcel request = Parcel .obtain ();
1628- Parcel reply = Parcel .obtain ();
1629- request .writeInterfaceToken (IMEDIA_PLAYER );
1630- request .writeInt (INVOKE_ID_ADD_EXTERNAL_SOURCE );
1631- request .writeString (path );
1632- request .writeString (mimeType );
1633- invoke (request , reply );
1628+ File file = new File (path );
1629+ if (file .exists ()) {
1630+ FileInputStream is = new FileInputStream (file );
1631+ FileDescriptor fd = is .getFD ();
1632+ addExternalSource (fd , mimeType );
1633+ is .close ();
1634+ } else {
1635+ // We do not support the case where the path is not a file.
1636+ throw new IOException (path );
1637+ }
16341638 }
16351639
16361640 /**
@@ -1671,8 +1675,6 @@ public void addExternalSource(Context context, Uri uri, String mimeType)
16711675 fd .close ();
16721676 }
16731677 }
1674-
1675- // TODO: try server side.
16761678 }
16771679
16781680 /* Do not change these values without updating their counterparts
@@ -1732,6 +1734,7 @@ public void addExternalSource(FileDescriptor fd, long offset, long length, Strin
17321734 if (!availableMimeTypeForExternalSource (mimeType )) {
17331735 throw new IllegalArgumentException ("Illegal mimeType for external source: " + mimeType );
17341736 }
1737+
17351738 Parcel request = Parcel .obtain ();
17361739 Parcel reply = Parcel .obtain ();
17371740 request .writeInterfaceToken (IMEDIA_PLAYER );
0 commit comments