我正在尝试使用videocaptur打开视频,但没有成功。 我尝试了不同的视频avi编解码器。
public void OnBtnStart(View view) {
String videopath = "android.resource://com.example.msi.mhltryagain/"+R.raw.testmjpeg;
VideoView videoview = (android.widget.VideoView) findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://com.example.msi.mhltryagain/"+R.raw.test);
videoview.setVideoURI(uri);
videoview.start();
VideoCapture cap = new VideoCapture(videopath);
boolean capGrab = cap.grab();
if (cap.isOpened()){
Toast.makeText(this,"is opened",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(this,"isn't opened"+capGrab,Toast.LENGTH_SHORT).show();
}
}
视频路径肯定很好,因为它正确播放测试视频。当我按下按钮时显示“isnt'opened false”。为什么视频无法打开?