MediaMetadataRetriever.setDataSource(本机方法)导致RuntimeException:status = 0x80000000 [英] MediaMetadataRetriever.setDataSource(Native Method) causes RuntimeException: status = 0x80000000

查看:374
本文介绍了MediaMetadataRetriever.setDataSource(本机方法)导致RuntimeException:status = 0x80000000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用android.media.MediaMetadataRetriever从android应用程序中的jpg文件中获取一些元数据信息.这是我的代码:

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);
}

当我调用setDataSource方法时,它将引发RuntimeException:

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)

奇怪的是,这仅在具有Android 4.2.2的HTC One X上失败.应用程序可以与具有其他Android版本(例如4.2.1)的其他设备配合使用.

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).

哇.也许是因为我对Maven的依赖关系不正确:

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>

但是我找不到android 4.2.2的依赖关系.在哪里可以找到它?

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

推荐答案

在API 10上打开文件并使用FileDescriptor似乎效果更好:

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();

这篇关于MediaMetadataRetriever.setDataSource(本机方法)导致RuntimeException:status = 0x80000000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆