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

前端 未结 10 1053
野性不改
野性不改 2020-12-09 01:57

I\'m developing a video streaming application and I\'m getting stuck when calling set setDataSource with a FileDescriptor. I want my application to play the video as it is b

10条回答
  •  囚心锁ツ
    2020-12-09 02:32

    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:

    MediaPlayer media = new MediaPlayer();
    TextView idenss;
    static private int PICKFILE_RESULT_CODE = 1;
    Boolean selectusicFromBworser = false;
    Button playGlobal;
    

    My code dialog:

    private void viewDialogSounds(final Button sountlabel){
        final View dialogView = View.inflate(this, R.layout.dialoge_selectsouns, null);
        final androidx.appcompat.app.AlertDialog alertDialog = new androidx.appcompat.app.AlertDialog.Builder(this).create();
    
        alertDialog.setTitle(context.getString(R.string.sound));
    
        Button exitW, play, pause, sound_set;
        ListView listsounds;
        SoundSteucture strAdapHistory = new SoundSteucture();
        ArrayList 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 = new ArrayList();
    
        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"};//indices
    
        final 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"};//archivos
    
        if (_adapterHistory != null) {
            _adapterHistory.clear(); //clear se usa solo con los arrayadapter, si fuera simple adapter llevaria removeAllViews
            _adapterHistory.notifyDataSetChanged();
        }
        for (int i=0;i

    My code ArrayAdapter:

    public class SoundAdapter extends ArrayAdapter {
    List imageAndTexts1 =null;
    Activity activity;
    Button pause,play;
    TextView fileSelectedName;
    ListView listItems;
    int PICKFILE_RESULT_CODE;
    
    
    public SoundAdapter(Activity activity, List 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;
    }
    
    static class ViewHolder {
        TextView labelFile;
        TextView fileName;
        ImageView deint;
    }
    
    public View getView(final int position, View rowView, ViewGroup parent) {
        activity = (Activity) getContext();
    
        ViewHolder holder = new ViewHolder();
    
        if (rowView == null) {
            LayoutInflater inflater = 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();
        }
    
        final String labelf = imageAndTexts1.get(position).getNames();
        final String labelN = imageAndTexts1.get(position).getIdentif();
        final String check = 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);
        }
    
        final ViewHolder finalHolder = holder;
        holder.labelFile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(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 browser
    private void openfilesFolder(){
        Intent chooseFile;
        Intent intent;
        chooseFile = new Intent(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:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    
        if (requestCode == PICKFILE_RESULT_CODE && resultCode == Activity.RESULT_OK) {
            Uri content_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();
        }
    }
    

提交回复
热议问题