我可以通过插入以下URL来播放来自互联网的视频:
mPath = Uri.parse("http://commonsware.com/misc/test2.3gp");
mVid.setVideoURI(mPath);
mVid.requestFocus();
mVid.start();
Run Code Online (Sandbox Code Playgroud)
但是现在我的原始文件夹中有一个视频,所以路径是res/raw/testing.3gp.下面的代码不起作用,我尝试了其他一些方法也无济于事.
mPath = Uri.parse("../../res/raw/testing.3gp");
Run Code Online (Sandbox Code Playgroud)
有什么建议?
Ale*_*ush 31
我有同样的问题.这对我有用:
Uri video = Uri.parse("android.resource://com.pac.myapp/raw/master");
Run Code Online (Sandbox Code Playgroud)
所以当你看到你有3个部分的uri:1)"android.resource://"2)"com.pac.myapp"3)"/ raw/master"
"master"是您视频的名称
小智 5
这对我有用
String videoName = nameWithoutFileExtention;
int id = getResources().getIdentifier(videoName, "raw", getActivity().getPackageName());
final String path = "android.resource://" + getActivity().getPackageName() + "/" + id;
vvBgVideo.setVideoURI(Uri.parse(path));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28817 次 |
| 最近记录: |