Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func stopRecording() {
- let recorder = RPScreenRecorder.shared()
- if isRecording {
- // 7-1. 사용자가 녹화 중간에 녹음을 종료하는 경우
- Log.warning?.message("Stop recording unexpectedly")
- recorder.stopRecording(handler: { (previewController, recordingError) in
- if let error = recordingError {
- Log.error?.message(error.localizedDescription)
- } else {
- // 현재 녹화되고 있던 내용을 모두 버립니다.
- recorder.discardRecording {
- self.timer?.invalidate()
- self.timer = nil
- self.currentLocation = 0
- }
- }
- })
- } else {
- // 7-2. 지도가 모두 움직인 후, 정상적으로 녹화 종료
- Log.info?.message("Stop recording normally")
- recorder.stopRecording(handler: { (previewController, recordingError) in
- if let error = recordingError {
- Log.error?.message(error.localizedDescription)
- } else {
- // 7-3. 녹화 결과를 보여주는 PreviewViewController 호출
- if let controller = previewController {
- controller.previewControllerDelegate = self
- self.present(controller, animated: true, completion: nil)
- } else {
- Log.warning?.message("There's no PreviewController")
- }
- }
- })
- }
- // 7-4. 녹화가 종료되면 화면을 초기 상태로 돌려줍니다.
- barButton.title = "Start Recording"
- showLocationOnMap(index: 0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement