0

a我在显示 SD 卡文件夹中的所有视频时遇到问题。目前,我能够显示 SD 卡中可以找到的所有视频,但我想做的是显示 SD 卡内“PartyVideo”文件夹中的所有视频。你能帮我吗?下面是我在 SD 卡中显示所有视频的代码。

final String[] columns = { MediaStore.Video.Media.DATA, MediaStore.Video.Media._ID };
    final String orderBy   = MediaStore.Video.Media.DATE_TAKEN;
    Cursor imagecursor     = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, columns, null,null, orderBy + " DESC");
    int image_column_index = imagecursor.getColumnIndex(MediaStore.Video.Media._ID);
    this.count             = imagecursor.getCount();
    this.thumbnails        = new Bitmap[this.count];
    this.arrPath           = new String[this.count];
    this.thumbnailsselection = new boolean[this.count];
    for (int i = 0; i < this.count; i++) 
    {
        imagecursor.moveToPosition(i);
        int id = imagecursor.getInt(image_column_index);
        int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Video.Media.DATA);
        thumbnails[i] = MediaStore.Video.Thumbnails.getThumbnail(
                getApplicationContext().getContentResolver(), id,
                MediaStore.Video.Thumbnails.MICRO_KIND, null);
        arrPath[i]= imagecursor.getString(dataColumnIndex);
    }
    GridView imagegrid = (GridView) findViewById(R.id.grid_GalleryImage);
    imageAdapter = new ImageAdapter();
    imagegrid.setAdapter(imageAdapter);

我尝试了许多不同的代码,最后得到了这个。下面的代码在我想要的文件夹中获取所有视频,但我不知道如何显示它。

String[] fileList = null;
     File videoFiles = new File(Environment.getExternalStorageDirectory()+"/PartyVideo");

        if(videoFiles.isDirectory())
        {
            fileList=videoFiles.list();
        }

       for(int i=0;i<fileList.length;i++)
       {
           Log.e("Video:"+i+" File name",fileList[i]);
       }
4

3 回答 3

2

使用此文件浏览器库浏览文件并将视频类型的过滤器放在以下代码中

Intent intent = new Intent(getBaseContext(), FileDialog.class);
intent.putExtra(FileDialog.START_PATH, "/sdcard");

 //can user select directories or not
intent.putExtra(FileDialog.CAN_SELECT_DIR, true);

 //alternatively you can set file filter
intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "avi" });

startActivityForResult(intent, REQUEST_SAVE);
于 2013-09-03T05:23:42.317 回答
1

试试这个希望它对你有用。 http://android-er.blogspot.in/2011/05/display-video-thumbnail-in-listview.html

于 2013-09-10T07:01:02.930 回答
1

尝试这个

Cursor videocursor = getActivity().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                        columns,
                        MediaStore.Video.Media.DATA + " like ? ",
                        new String[]{"%/" + Your folder name + "/%"},
                        null);
于 2015-07-13T13:44:12.857 回答