如何解决当某些中断来临时,如何防止相机暂停视频录制
在我的应用中,我正在录制视频。所以基本上我想在有人试图给我打电话时暂停视频录制。通话后我想继续录音。这是我停止视频录制的代码。
Future<void> stopVideoRecording() async {
if (!controller.value.isRecordingVideo) {
return null;
}
try {
Wakelock.disable();
await controller.stopVideoRecording();
if (_recordingTimer.isActive) {
_recordingTimer.cancel();
videoSegments.last.seconds = _segmentTime;
_segmentTime = 0;
print('LOG: stopped at $curVideoLength');
}
} on CameraException catch (e) {
_showCameraException(e);
return null;
}
if (videoSegments.length > 1) {
if (!cameraHasFlipped &&
videoSegments[videoSegments.length - 2].camera !=
videoSegments.last.camera) {
cameraHasFlipped = true;
alternateCamera = videoSegments.last.camera;
}
if (cameraHasFlipped && videoSegments.last.camera == alternateCamera) {
final Directory extDir = await getApplicationDocumentsDirectory();
final String dirPath = '${extDir.path}/Movies/flutter/Mandaboo';
await Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}_flipped.mp4';
await _flutterFFmpeg
.execute("-i ${videoSegments.last.filePath} -vf 'hflip' $filePath");
// await _flutterFFmpeg.execute('-i ${videoList.last} -metadata:s:v rotate="90" -codec copy $filePath');
videoPath = filePath;
videoSegments.last.filePath = videoPath;
}
}
// play back the last recorded clip
await _startVideoPlayer();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。