Reputation: 421
How can I get a list of all videos from a folder on the sdcard and display the thumbnails in a list? When I click on a thumbnail, it should then open that video for playback.
Please help me out.
Upvotes: 1
Views: 1097
Reputation: 10635
We can't give you whole code. Just suggestion from me that how you can achieve that. you can use that code to see media in your particular folder.
String fileUrl = "/myfolder/";
String MEDIA_PATH = android.os.Environment.getExternalStorageDirectory().getPath() +
fileUrl;
And here is filter code for searching particular extension.
class Mp4Filter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(".mp4"));
}
}
For generating thumbnails in listview go here
For starting video on click, You need to implement onListItemClick. Like that:-
protected void onListItemClick(ListView l, View v, int position, long id) {
currentPosition = position;
playSong(MEDIA_PATH + songs.get(position));
Toast.makeText(getApplicationContext(), "Video Start",
Toast.LENGTH_LONG).show();
}
Upvotes: 1