Exception When Calling Setdatasource(filedescriptor) Method (failed.: Status=0x80000000)
Solution 1:
Don't forgot permission
<uses-permissionandroid:name="android.permission.INTERNET" />
Solution 2:
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.
Solution 3:
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
Solution 4:
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.
FilemediaStorageDir=newFile(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "MyDirectoryUnderPictures");
File mediaFile_mp4_android;
mediaFile_mp4_android = newFile(mediaStorageDir.getPath()
+ File.separator
+ "mp4_test"
+ ".mp4"); //video taken with android cameraStringfilePath_mp4_android= String.valueOf(mediaFile_mp4_android);
Filefile_mp4_android=newFile(filePath_mp4_android);
UricontentUri= Uri.fromFile(file_mp4_android);
MediaMetadataRetrievermmr=newMediaMetadataRetriever();
mmr.setDataSource(String.valueOf(contentUri));
Solution 5:
I also have that problem. When I select the audio from SDCard by library it works, and if I press stop and start again, too. But when restarting the app, and I play without open library, only with url saved, it stops working, and returns that error: 'java.io.IOException: setDataSource failed.: status=0x80000000'
Global Vars:
MediaPlayermedia=newMediaPlayer();
TextView idenss;
staticprivateintPICKFILE_RESULT_CODE=1;
BooleanselectusicFromBworser=false;
Button playGlobal;
My code dialog:
privatevoidviewDialogSounds(final Button sountlabel){
finalViewdialogView= View.inflate(this, R.layout.dialoge_selectsouns, null);
final androidx.appcompat.app.AlertDialogalertDialog=newandroidx.appcompat.app.AlertDialog.Builder(this).create();
alertDialog.setTitle(context.getString(R.string.sound));
Button exitW, play, pause, sound_set;
ListView listsounds;
SoundSteucturestrAdapHistory=newSoundSteucture();
ArrayList<SoundSteucture> structureHistoryArr;
SoundAdapter_adapterHistory=null;
final TextView fileSelectedName;
exitW = (Button) dialogView.findViewById(R.id.exitW);
play = (Button) dialogView.findViewById(R.id.play);
pause = (Button) dialogView.findViewById(R.id.pause);
sound_set = (Button) dialogView.findViewById(R.id.sound_set);
listsounds = (ListView) dialogView.findViewById(R.id.listsounds);
fileSelectedName = (TextView) dialogView.findViewById(R.id.fileSelectedName);
idenss = fileSelectedName;
playGlobal = play;
structureHistoryArr = newArrayList<SoundSteucture>();
fileSelectedName.setText(sountlabel.getText().toString());
String [] LabelNames={"A desayunar","A la valenciana","Al currele","Apagas o apagas","Arroz 3 delicias","Clásico e infalible","Con café mejor",
"De buen humor","El coche fantástico","El gallo Claudio","Energía positiva","Final destroyer","Fresas con nata","Manos arriba","Profundidad",
"Sabanas pegadas","Sax o Phone","Tocando el cielo"};//indicesfinal String [] fileNames={"a_desayunar","a_la_valenciana","al_currele","apagas_o_apagas","arroz_3_delicias","clasico_e_infalible","con_cafe_mejor",
"de_buen_humor","el_coche_fantastico","el_gallo_claudio","energia_positiva","final_destroyer","fresas_con_nata","manos_arriba","profundidad",
"sabanas_pegadas","sax_o_phone","tocando_el_cielo"};//archivosif (_adapterHistory != null) {
_adapterHistory.clear(); //clear se usa solo con los arrayadapter, si fuera simple adapter llevaria removeAllViews
_adapterHistory.notifyDataSetChanged();
}
for (int i=0;i<LabelNames.length;i++){
strAdapHistory.setNames(LabelNames[i]);
strAdapHistory.setIdentif(fileNames[i]);
if(fileSelectedName.getText().toString().equals(fileNames[i].replace("_"," ")))
strAdapHistory.setCheck("1"); //consultadorelse
strAdapHistory.setCheck("0");
structureHistoryArr.add(strAdapHistory);
strAdapHistory = newSoundSteucture();
}
if (structureHistoryArr != null) {
_adapterHistory = newSoundAdapter(this, structureHistoryArr,pause, play, fileSelectedName, listsounds, PICKFILE_RESULT_CODE);
listsounds.setAdapter(_adapterHistory);
_adapterHistory.notifyDataSetChanged();
}
pause.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
selectusicFromBworser = false;
try {
if (media != null) {
media.stop(); //error
media = null;
media = newMediaPlayer();
}
} catch(Exception e){
Log.d("Nitif Activity", e.toString());
}
}
});
finalButtonpauseFinal= pause;
play.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
if(!fileSelectedName.getText().toString().equals(getString(R.string.sound))) {
pauseFinal.callOnClick();
intresID=0;
if (!fileSelectedName.getText().toString().contains("/")) {
Stringtono= fileSelectedName.getText().toString().replace(" ","_");
resID = getResources().getIdentifier(tono, "raw", getPackageName());
media = MediaPlayer.create(view.getContext(), resID);
media.setVolume(1000, 1000);
media.start();
} else {
try {
if (!selectusicFromBworser) {
media.setDataSource(context, Uri.parse(fileSelectedName.getText().toString()));
}
media.prepareAsync();
media.setOnPreparedListener(newMediaPlayer.OnPreparedListener() {
@OverridepublicvoidonPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
}
});
} catch (Exception e) {
e.printStackTrace();
Log.e("eeee???", e.toString());
}
}
}
}
});
exitW.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
pauseFinal.callOnClick();
alertDialog.dismiss();
selectusicFromBworser = false;
}
});
sound_set.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
selectusicFromBworser = false;
if((!fileSelectedName.getText().toString().equals(""))&&(!fileSelectedName.getText().toString().equals("fileB")))
sountlabel.setText(fileSelectedName.getText().toString().replace("_"," "));
pauseFinal.callOnClick();
alertDialog.dismiss();
}
});
alertDialog.setView(dialogView);
alertDialog.show();
}
My code ArrayAdapter:
publicclassSoundAdapterextendsArrayAdapter<SoundSteucture> {
List<SoundSteucture> imageAndTexts1 =null;
Activity activity;
Button pause,play;
TextView fileSelectedName;
ListView listItems;
int PICKFILE_RESULT_CODE;
publicSoundAdapter(Activity activity, List<SoundSteucture> imageAndTexts, Button pause, Button play, TextView fileSelectedName, ListView listItems, int PICKFILE_RESULT_CODE) {
super(activity, 0, imageAndTexts);
imageAndTexts1 = imageAndTexts;
this.pause = pause;
this.play = play;
this.fileSelectedName = fileSelectedName;
this.listItems = listItems;
this.PICKFILE_RESULT_CODE = PICKFILE_RESULT_CODE;
}
staticclassViewHolder {
TextView labelFile;
TextView fileName;
ImageView deint;
}
public View getView(finalint position, View rowView, ViewGroup parent) {
activity = (Activity) getContext();
ViewHolderholder=newViewHolder();
if (rowView == null) {
LayoutInflaterinflater= activity.getLayoutInflater();
rowView = inflater.inflate(R.layout.adapter_sounds, parent, false);
holder.labelFile = (TextView)rowView.findViewById(R.id.labelFile);
holder.fileName = (TextView)rowView.findViewById(R.id.fileName);
holder.deint = (ImageView) rowView.findViewById(R.id.deint);
rowView.setTag(holder);
}else {
holder = (ViewHolder) rowView.getTag();
}
finalStringlabelf= imageAndTexts1.get(position).getNames();
finalStringlabelN= imageAndTexts1.get(position).getIdentif();
finalStringcheck= imageAndTexts1.get(position).getCheck();
holder.labelFile.setText(labelf);
holder.fileName.setText(labelN);
if(check.equals("1")){
holder.deint.setVisibility(View.VISIBLE);
}else{
holder.deint.setVisibility(View.GONE);
}
finalViewHolderfinalHolder= holder;
holder.labelFile.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
ImageView imageList;
for(int a=0; a < listItems.getCount(); a++){
try {
imageList = (ImageView) listItems.getChildAt(a).findViewById(R.id.deint);
imageList.setVisibility(View.GONE);
}
catch(Exception e1){ //if not checkBox, null View, etc
}
}
for(int j=0; j < imageAndTexts1.size(); j++){
imageAndTexts1.get(j).setCheck("0");
}
if(check.equals("0")){
finalHolder.deint.setVisibility(View.VISIBLE);
imageAndTexts1.get(position).setCheck("1");
}else{
finalHolder.deint.setVisibility(View.GONE);
imageAndTexts1.get(position).setCheck("0");
}
fileSelectedName.setText(labelN.replace("_"," "));
if(!finalHolder.labelFile.getText().equals("fileB"))
play.callOnClick();
else
openfilesFolder();
}
});
return rowView;
}
//files browserprivatevoidopenfilesFolder(){
Intent chooseFile;
Intent intent;
chooseFile = newIntent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("audio/*");
//chooseFile.setType("*/*");
intent = Intent.createChooser(chooseFile, activity.getString(R.string.choosefile));
activity.startActivityForResult(intent, PICKFILE_RESULT_CODE);
}
Activity Result in Principal Activity:
@OverridepublicvoidonActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICKFILE_RESULT_CODE && resultCode == Activity.RESULT_OK) {
Uricontent_describer= data.getData();
Log.e("eeee???", "ee->" + data.getData().getPath());
idenss.setText(content_describer.toString());
selectusicFromBworser = true;
try {
media.setDataSource(this, content_describer);
} catch (IOException e) {
e.printStackTrace();
}
playGlobal.callOnClick();
}
}
Post a Comment for "Exception When Calling Setdatasource(filedescriptor) Method (failed.: Status=0x80000000)"