Hey I just saw that I forgot s.th. within  getCount(), so I changed it to

 public int getCount() {
               //return mThumbIds.length;
          if(vidUris!=null){
               return vidUris.length;}
               return 0;
           }

The thing now is that I still cannot see any videos displayed in my
GridView, but I get a message saying: "Sorry, but this video cannot be
played!"

As I don't want to play the videos but only display them in the GridView
like in an directory, do I maybe have to use MediaStore.Video.Thumbnails
instead, which I just found when I googled a little...though I don't know
what I should do with it in my code...if someone could help me out here,
that would be really really great... Thanks



On Sat, Jul 17, 2010 at 12:13 PM, kivy <victoriasarabu...@gmail.com> wrote:

> Hi there,
>
> I am trying to display videos form the emulated sdcard, but it seems
> that I have done something wrong because no video thumbs are displayed
> within my gridview... it would be great if someone could help me out,
> because I have no idea at the moment what I may have done wrong...
> Thank you in advance...
>
> Here is my code of the java file...
>
>
>
>
> package com.mobilevideoeditor.moved;
>
> import java.util.ArrayList;
>
> import android.app.Activity;
> import android.content.Context;
> import android.database.Cursor;
> import android.net.Uri;
> import android.os.Bundle;
> import android.provider.MediaStore;
> import android.util.Log;
> import android.view.View;
> import android.view.ViewGroup;
> import android.widget.BaseAdapter;
> import android.widget.GridView;
> import android.widget.VideoView;
>
>
>
>
> public class EditGalleryView extends Activity {
>        Uri[] vidUris;
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.videogrid);
>
>        GridView vGrid=(GridView) findViewById(R.id.vgrid);
>        vGrid.setAdapter(new VideoAdapter(this));
>
>        Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
>
>        Log.d("EditGalleryView", "uri:"+uri);
>        String[] projection = {
>                MediaStore.Video.Media.DESCRIPTION,
>                MediaStore.Video.Media.DATA
>
>    };
>
>        Cursor c = this.managedQuery(uri, projection, null, null,
>                        MediaStore.Video.Media.DATE_ADDED);
>                                 Log.d("EditGalleryView", "vids available:"
> +c.getCount());
>
>                                 ArrayList<Uri> experimentVids = new
> ArrayList<Uri>();
>
>
>                                     if (c.getCount() != 0) {
>                                         c.moveToFirst();
>
> experimentVids.add(Uri.parse(c.getString(1)));
>                                         while (c.moveToNext()) {
>
> experimentVids.add(Uri.parse(c.getString(1)));
>
>                                          }
>                              }
>                                     Log.d("ClassName",
> "experimentVids.length:"
> +experimentVids.size());
>                                                              if
> (experimentVids.size() != 0)
> {
>                                                                vidUris =
> new
> Uri[experimentVids.size()];
>                                                                  for (int i
> = 0; i <
> experimentVids.size(); i++) {
>
>  vidUris[i] =
> experimentVids.get(i);
>                                                                  }
>
>  Log.d("EditGalleryView",
> "vidUris:"+vidUris.length);
>                                                              }
>                                                          }
>
>
>    public class VideoAdapter extends BaseAdapter {
>        private Context mContext;
>
>                public VideoAdapter(Context c) {
>                    mContext = c;
>            }
>
>            public int getCount() {
>                //return mThumbIds.length;
>           if(vidUris!=null){
>                return vidUris.length;}
>                return 0;
>            }
>
>
>            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) {
>               VideoView videoView;
>                if (convertView == null) {  // if it's not recycled,
> initialize some attributes
>                    videoView = new VideoView(mContext);
>                    videoView.setVideoURI(vidUris[position]);
>                    videoView.setLayoutParams(new GridView.LayoutParams(85,
> 85));
>
> //videoView.setScaleType(VideoView.ScaleType.CENTER_CROP);
>                    videoView.setPadding(8, 8, 8, 8);
>                } else {
>                    videoView = (VideoView) convertView;
>                }
>
>              //  imageView.setImageResource(mThumbIds[position]);
>                return videoView;
>            }
>
>           /* // references to our images
>            private Integer[] mThumbIds = {
>                    R.drawable.sample_2, R.drawable.sample_3,
>                    R.drawable.sample_4, R.drawable.sample_2,
>                    R.drawable.sample_6, R.drawable.sample_3,
>                    R.drawable.sample_4, R.drawable.sample_1,
>
>            };*/
>
>    }
>
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to