Reputation: 8946
I am developing a project in which i need to play Audio and Video files. When audio player is clicked i should display only audio files from sdcard and play those files.
When video player is clicked i only need to display video files and play those video files.
I am using media player for playing the files.
MediaPlayer mp = new MediaPlayer();
String filepath = Environment.getExternalStorageDirectory()+"/f.mp3";
mp.setDataSource(filepath);
mp.start();
But My problem is,how to browse the audio/video files and set the data source dynamically when the user selects a particular file.
Upvotes: 0
Views: 1605
Reputation: 11230
You Should use MediaStore which has separate ContentProvider for audio and video
http://developer.android.com/reference/android/provider/MediaStore.html
Audio : http://developer.android.com/reference/android/provider/MediaStore.Audio.html
Video : http://developer.android.com/reference/android/provider/MediaStore.Video.html
Upvotes: 1