Hi,
I am working on a video app. And I have created a GridView that shall
display any video stored on the sdcard. Currently it only displays the
name of the video file.
I wanted to ask if and how it would be possible instead of showing
only the name to also display thumbs (or a frame preview) of the
videos ?!?
I would be grateful for any help...thanks.
This is the code I have used so far:
I am working on a video app. And I have created a GridView that shall
display any video stored on the sdcard. Currently it only displays the
name of the video file.
I wanted to ask if and how it would be possible instead of showing
only the name to also display thumbs (or a frame preview) of the
videos ?!?
I would be grateful for any help...thanks.
This is the code I have used so far:
Code:
package com.mobilevideoeditor.moved;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
public class EditGalleryView extends Activity {
private Cursor videocursor;
private int video_column_index;
int count;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videogrid);
init_phone_video_grid();
}
private void init_phone_video_grid() {
System.gc();
String[] proj = {
MediaStore.Video.Media._ID,
MediaStore.Video.Media.DISPLAY_NAME,
MediaStore.Video.Media.DATA
};
videocursor =
managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null,
null, null);
count = videocursor.getCount();
GridView vGrid=(GridView) findViewById(R.id.vgrid);
vGrid.setAdapter(new VideoAdapter(this));
}
public class VideoAdapter extends BaseAdapter {
private Context vContext;
public VideoAdapter(Context c) {
vContext = c;
}
public int getCount() {
//return mThumbIds.length;
return count;
}
public Object getItem(int position) {
//return null;
return position;
}
public long getItemId(int position) {
//return 0;
return position;
}
// create a new ImageView for each item referenced by the
Adapter
public View getView(int position, View convertView,
ViewGroup parent) {
System.gc();
TextView tv = new
TextView(vContext.getApplicationContext());
String id = null;
if (convertView == null) {
video_column_index =
videocursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
videocursor.moveToPosition(position);
id = videocursor.getString(video_column_index);
tv.setText(id);
} else
tv = (TextView) convertView;
return tv;
}
}