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 11:15 AM, Victoria <victoriasarabu...@gmail.com>wrote:

> Hi there,
>
> I am looking for a way to display the videos as thumbnails from my
> sdcard in a GridView. The way I tried doesn't seem to work, they don't
> show in the emulator...but I have no idea where I have done something
> wrong. If someone could give me a hand here, that would be great.
> Thank you very much in advance. Cheers.
>
> This is the code I am using to access the videos:
>
>    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 Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to