Trying to play video from raw folder (VideoView)

前端 未结 4 1728
悲&欢浪女
悲&欢浪女 2020-12-05 10:45

I can play a video from the Internet by inserting the URL like below:

mPath   = Uri.parse(\"http://commonsware.com/misc/test2.3gp\");
mVid.setVideoURI(mPath)         


        
4条回答
  •  春和景丽
    2020-12-05 11:36

    this works for me

     String videoName = nameWithoutFileExtention;
    
     int id = getResources().getIdentifier(videoName, "raw", getActivity().getPackageName());
    
     final String path = "android.resource://" + getActivity().getPackageName() + "/" + id;
    
     vvBgVideo.setVideoURI(Uri.parse(path));
    

提交回复
热议问题