我在使用 MediaMetadataRetriever 检索 mp3 文件的艺术家和标题时收到错误消息(setDataSource failed 0x8000000),但我不明白为什么。在我的模拟器上运行时,它运行良好,但在我的三星 S4 上运行时崩溃。我知道目录是正确的(/storage/extSdCard/Music/),因为我可以毫无问题地加载文件名。有人可以解释为什么这不起作用吗?
if (songs.size() != 0){
for (int x = 0; x < songs.size(); x++){
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(SD_PATH + songs.get(x));
String tagTitle =
mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
String tagArtist =
mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
taggedSongs.add(tagArtist + " - " + tagTitle);
}
ArrayAdapter<String> songList = new ArrayAdapter<String>(this,R.layout.song_item,taggedSongs);
编辑:
日志猫:
09-15 10:55:02.805: E/AndroidRuntime(1292): FATAL EXCEPTION: main
09-15 10:55:02.805: E/AndroidRuntime(1292): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jimmy.jimp3/com.jimmy.jimp3.MainActivity}: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2249)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.ActivityThread.access$700(ActivityThread.java:154)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.os.Handler.dispatchMessage(Handler.java:99)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.os.Looper.loop(Looper.java:137)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.ActivityThread.main(ActivityThread.java:5306)
09-15 10:55:02.805: E/AndroidRuntime(1292): at java.lang.reflect.Method.invokeNative(Native Method)
09-15 10:55:02.805: E/AndroidRuntime(1292): at java.lang.reflect.Method.invoke(Method.java:511)
09-15 10:55:02.805: E/AndroidRuntime(1292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
09-15 10:55:02.805: E/AndroidRuntime(1292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
09-15 10:55:02.805: E/AndroidRuntime(1292): at dalvik.system.NativeStart.main(Native Method)
09-15 10:55:02.805: E/AndroidRuntime(1292): Caused by: java.lang.RuntimeException: setDataSource failed: status = 0x80000000
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.media.MediaMetadataRetriever.setDataSource(Native Method)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:66)
09-15 10:55:02.805: E/AndroidRuntime(1292): at com.jimmy.jimp3.MainActivity.taggedPlaylist(MainActivity.java:78)
09-15 10:55:02.805: E/AndroidRuntime(1292): at com.jimmy.jimp3.MainActivity.onCreate(MainActivity.java:47)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.Activity.performCreate(Activity.java:5255)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
09-15 10:55:02.805: E/AndroidRuntime(1292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2213)
09-15 10:55:02.805: E/AndroidRuntime(1292): ... 11 more