显示Android中SD卡中特定文件夹中的所有视频

时间:2013-09-03 05:17:37

标签: android android-videoview video-thumbnails

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]);
       }

3 个答案:

答案 0 :(得分:2)

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

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);

答案 1 :(得分:1)

试试这个

$('body').find([all elements with position == fixed]);

答案 2 :(得分:0)