我将从原始文件夹中加载所有视频并使用mediaplayr显示。为此使用以下代码但获得异常。怎么了? 感谢
String filePath = "android.resource://" + this.getPackageName() + "/raw/";
ContentResolver resolver=getContentResolver();
String projection[]= {MediaStore.Video.Media._ID,MediaStore.Video.Media.DISPLAY_NAME,MediaStore.Video.Media.DURATION};
Cursor cursor= resolver.query(MediaStore.Video.Media.INTERNAL_CONTENT_URI ,projection, MediaStore.MediaColumns.DATA+ "='"+filePath+"'", null, null);
videoDetails=new ArrayList<VideoInfo>();
while(cursor.moveToNext())
{
int id=cursor.getInt(0);
String title=cursor.getString(1);
int dur=cursor.getInt(2);
videoDetails.add(new VideoInfo(id,title,dur));
}
答案 0 :(得分:0)
您可以使用此功能播放原始视频
String UrlPath="android.resource://"+getPackageName()+"/"+R.raw.ur_file_name;
videocontainer.setVideoURI(Uri.parse(UrlPath));
videocontainer.start();
代码来自主教Fakhry 来自how-to-play-videos-in-android-from-assets-folder-or-raw-folder