I have multiple audio files in res/raw
folder. I showing ListView
that contains audio files name. I want to play the corresponding audio file when user select into the ListView
. I have used setDataSource(path)
, but it showing error while playing. How play the audio files directly from that folder? Or Is there any other way?
Open File Manager and navigate to the folder where the audio file is located. Drag the audio file icon from File Manager and drop it on the Audio main window. The Selected file is opened. If Automatically play audio file on Open is selected in the Options-Play dialog box, the audio file starts playing.
Create raw folder under res folder. It must be in a supported format (3gp, wmv, mp4 ) and named with lower case, numerics, underscores and dots in its filename likewise:video_file. mp4. VideoView view = (VideoView)findViewById(R.
The file manager is not intended to play audio file, so this will not work. The Audio-Player app is the right choice for this job. If you want to play files from a folder, I recommend to select the option “folder” in the pull-down in the upper left corner of the app.
add this code in onItemClickListener.
listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position,long id) { TextView txtView=(TextView)view.findViewById(R.id.txt_view); String fname=txtView.getText().toString().toLowerCase(); int resID=getResources().getIdentifier(fname, "raw", getPackageName()); MediaPlayer mediaPlayer=MediaPlayer.create(this,resID); mediaPlayer.start(); } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With