如何获得在Android设备上的所有视频 [英] How to get all videos on Android device

查看:179
本文介绍了如何获得在Android设备上的所有视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获得的所有视频和它们的路径,可以安装我的应用程序,其中Android设备上找到一个列表?

编辑: 我试图做一个简单的视频播放器,这样的想法是将显示所有可在设备上找到的视频,并发挥它在列表项的点击。 唯一的问题是,我不知道如何获取有关影片的信息,所以我会非常感激,如果有人能帮助我。

解决方案

 的String []投影= {MediaStore.Video.Media._ID};
光标光标=新CursorLoader(背景下,MediaStore.Video.Media.EXTERNAL_CONTENT_URI,投影,
            空,//返回所有行
            NULL,NULL).loadInBackground();
 

在你的光标,你可以重复它,并使用视频ID得到所有影片。

How can I get a list of all videos and their path that can be found on an Android device where is my app installed?

EDIT: I am trying to make a simple video player, so the idea would be to display all the videos that can be found on the device and to play it on list item click. Only problem is that i don't know how to get that info about videos, so I would be very thankful if someone can help me.

解决方案

String[] projection = { MediaStore.Video.Media._ID};
Cursor cursor = new CursorLoader(contexts, MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, 
            null, // Return all rows
            null, null).loadInBackground();

after you have the cursor you can iterate it and get all videos using the video id.

这篇关于如何获得在Android设备上的所有视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆