Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play the audio files directly from res/raw folder?

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?

like image 480
bharath Avatar asked Sep 21 '11 12:09

bharath


People also ask

How do I get audio files to play?

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.

How do I play a raw video folder?

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.

How do I play audio files in file manager?

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.


1 Answers

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();             }         }); 
like image 105
ilango j Avatar answered Sep 29 '22 08:09

ilango j