如何获得在Android设备上的所有视频如何获得、设备、视频、Android

2023-09-06 01:13:47 作者:狼少°

我怎样才能获得的所有视频和它们的路径,可以安装我的应用程序,其中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?

一种 在 Android 设备上,播放视频的同时,获取实时音频流 的有效方案

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.