Exception when calling setDataSource(FileDescriptor) method (failed.: status=0x80000000)

流过昼夜 提交于 2019-11-27 20:25:45

Don't forgot permission

<uses-permission android:name="android.permission.INTERNET" /> 
Pedriyoo

Okay, I've arrived to the conclusion that errors like:

Prepare failed.: status=0x1 (when calling prepare() )

and

setDataSourceFD failed.: status=0x80000000 (when calling setDataSourceFD() )

have to do with the file format and probably mean that the file is incomplete, corrupted or something like that...

As I have post in this link, I've found an specific video which works fine while streaming it (though I use setDataSource, not setDataSourceFD), but it'll not work with most of the videos.

Sean

From what I have read, certain video file formats have their "header" information on the END of the file. Thus your FD must be support seek function to get the "header" from the end of the file. I suspect your input file to media player fails when it seeks to the "end" of the file.

We are working on the same issues have you gotten further?

Sean

having the same error, and having read the answer above on file format, I abandonded trying to setDataSource with my .mov file and instead created a video with my Android Telefon Camera which gave me an .mp4 file. I put this in the directory Pictures/. This worked - I cound setDataSource without errors. I hope this is useful to someone.

File mediaStorageDir = new         File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES),     "MyDirectoryUnderPictures");
File mediaFile_mp4_android;
mediaFile_mp4_android = new File(mediaStorageDir.getPath()
                    + File.separator
                    + "mp4_test"
                    + ".mp4"); //video taken with android camera
String filePath_mp4_android = String.valueOf(mediaFile_mp4_android);
File file_mp4_android = new File(filePath_mp4_android);
Uri contentUri = Uri.fromFile(file_mp4_android);
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(String.valueOf(contentUri));

In my case switching from wav file to mp3 solved this exception with status=0x80000000

In my case the problem was because of beasy sdcard when device was mounted as exteranl storage to pc so checking if the file is available solved the problem. Maybe it helps someone

If you're targeting Marshmallow or greater, make sure that you have requested the Manifest.permission.WRITE_EXTERNAL_STORAGE permission properly. I tried many different solutions, including another library that's an alternative to MediaMetadataRetriever, but it turned out that one of my code paths didn't request the proper permission.

I was facing the same issue while loading video from obb extension file. i fixed it by replacing:

mPlayer.setDataSource(fd); 

with:

mPlayer.setDataSource(fis.getFileDescriptor(),fis.getStartOffset(),fis.getLength());

I agree with Pedriyoo, I tried reproducing the exception with different video file formats and out of the following video formats: AVI, MPG/MPEG, MOV, mov, mp4, m4v, flv, WMV, I noticed that AVI, MPG/MPEG, and WMV threw an exception for me every time. Better to exclude them before running the method and wrap it with a try-catch.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!