在我的项目中,我想在启动手机的屏幕录像机时停止视频(使用action_video_capture目的通过应用程序录制的视频)。我到处都找不到合适的答案。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView=this.findViewById(R.id.video_view);
capture_video=this.findViewById(R.id.capture_video);
play_video=this.findViewById(R.id.play_video);
stop_video=this.findViewById(R.id.stop_video);
capture_video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent captureVideoIntent =new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(captureVideoIntent,VIDEO_CAPTURED);
}
});
play_video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
videoView.setVideoURI(videoFileUri);
videoView.resume();
videoView.start();
stop_video.setEnabled(true);
}
});
stop_video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
videoView.stopPlayback();
}
});
play_video.setEnabled(false);
stop_video.setEnabled(false);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (resultCode == RESULT_OK && requestCode == VIDEO_CAPTURED) {
videoFileUri = data.getData();
play_video.setEnabled(true);
}
}
播放视频时,我并没有得到停止手机屏幕录制的实际操作。