-3

I will load all video from raw folder and show it with mediaplayr. for this use following code but get Exception. what is wrong? thanks

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

     }
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
mehdi
  • 1
  • 1
  • 1
    Possible duplicate of [How to play videos in android from assets folder or raw folder?](http://stackoverflow.com/questions/3028717/how-to-play-videos-in-android-from-assets-folder-or-raw-folder) – OneCricketeer Sep 24 '16 at 20:04

1 Answers1

0

You can play the videos from raw using this function

String  UrlPath="android.resource://"+getPackageName()+"/"+R.raw.ur_file_name;
videocontainer.setVideoURI(Uri.parse(UrlPath));
videocontainer.start();

Code taken from bishop Fakhry From here how-to-play-videos-in-android-from-assets-folder-or-raw-folder

Community
  • 1
  • 1
Jayanth
  • 5,954
  • 3
  • 21
  • 38
  • but with this code i can load just one file . i have more than 30 file and will create a dynamic code to load all files from the raw foldr – mehdi Sep 25 '16 at 15:31