[英]Android VideoView can't play video in “file:///android_asset/…”
I'm trying to play video: 我正在尝试播放视频:
mVideoView = (VideoView) findViewById(R.id.surface_view);
String viewSource = "file:///android_asset/intro.mp4";
Uri uri = Uri.parse(viewSource);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
but nothing works. 但没有任何效果。 LogCat shows me just this: "MediaPlayer Error(1, -2147483648)"
LogCat仅向我显示了这一点:“ MediaPlayer Error(1,-2147483648)”
If i try to play video from res/raw directory, everythig works fine! 如果我尝试从res / raw目录播放视频,everythig可以正常工作! But i need to play from ASSETS!!!
但是我需要从资产中打球!!!
Thanks. 谢谢。
Start the video from callback that the player provides in this manner: 从播放器以这种方式提供的回调开始视频:
mVideoView.setVideoPath("android.resource://<<package>>/raw/video");
mVideoView.requestFocus();
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mVideoView.start();
}
});
mVideoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.