Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaMetadataRetriever.setDataSource(Native Method) causes RuntimeException: status = 0x80000000

Tags:

android

I try to get some metadata informations from jpg file in my android app using android.media.MediaMetadataRetriever. Here is my code:

public long getDuration(String videoFilePath, Context context) {
    File file = loadVideoFile(videoFilePath);
    if (file == null) {
        return -1;
    }

    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    file.setReadable(true, false);
    retriever.setDataSource(file.getAbsolutePath());
    return getDurationProperty(retriever);
}

When I call setDataSource method it throws RuntimeException:

09-10 15:22:25.576: D/PowerManagerService(486): releaseWakeLock(419aa2a0): CPU_MIN_NUM , tag=AbsListViewScroll_5.0, flags=0x400
09-10 15:22:26.481: I/HtcModeClient(12704): handler message = 4011
09-10 15:22:26.481: E/HtcModeClient(12704): Check connection and retry 9 times.
09-10 15:22:27.681: W/dalvikvm(13569): threadid=1: thread exiting with uncaught exception (group=0x40bc92d0)
09-10 15:22:27.696: E/AndroidRuntime(13569): FATAL EXCEPTION: main
09-10 15:22:27.696: E/AndroidRuntime(13569): java.lang.RuntimeException: setDataSource failed: status = 0x80000000
09-10 15:22:27.696: E/AndroidRuntime(13569):    at android.media.MediaMetadataRetriever.setDataSource(Native Method)
09-10 15:22:27.696: E/AndroidRuntime(13569):    at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:66)

And strange is that this fails only on HTC One X with Android 4.2.2. Applications works fine with other devices which has other android versions (for example 4.2.1).

Edit:

wow. Maybe it is about my wrong dependency in maven:

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>android</artifactId>
    <version>4.1.1.4</version>
    <scope>provided</scope>
</dependency>

But I can't find dependency for android 4.2.2. Where I can find it?

like image 920
Mirek Avatar asked Oct 03 '22 21:10

Mirek


1 Answers

Opening the file yourself and using the FileDescriptor seems to work better on API 10:

FileInputStream inputStream = new FileInputStream(file.getAbsolutePath());
retriever.setDataSource(inputStream.getFD());
inputStream.close();
like image 194
Benoit Avatar answered Oct 07 '22 19:10

Benoit