tags:

views:

24

answers:

0

I am downloading an audio from server and inserting it in media gallery. I get the uri of the audio and starts the default audio player with this uri. When the player starts it throws throws exception.

ERROR/AndroidRuntime(564): Uncaught handler: thread album art worker exiting due to uncaught exception
ERROR/AndroidRuntime(564): java.lang.IllegalStateException: Unknown URL: content://media/external/audio/albumart/-1

However this thing does not happen on HTC G1. Can Some One Please figure out the issue.

here is the code for inserting the audio

File file = File.createTempFile("fileName", ".
ContentValues values = new ContentValues(3);
values.put(MediaStore.Audio.Media.TITLE, "" + dObject.getFilename());
values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/mp3");
values.put(MediaStore.Audio.Media.DATA, file.getAbsolutePath());

 ParcelFileDescriptor discriptor = context.getContentResolver().openFileDescriptor(uri, "rwt");
FileDescriptor fDiscriptor = discriptor.getFileDescriptor();
FileOutputStream out = new FileOutputStream(fDiscriptor);

byte buf[] = new byte[32 * 1024];
do {

    if (isCancelled) {
    file.delete();
    context.getContentResolver().delete(uri, null, null);
    uri = null;
    break;
}
numread = inputStream.read(buf);
if (numread <= 0)
break;
out.write(buf, 0, numread);
 } while (numread > 0);
out.flush();
out = null;
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri));

Code for opening the gallery:

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(path),"audio/*");
        startActivity(intent);

Thanks in advance