Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. func stopRecording() {
  2. let recorder = RPScreenRecorder.shared()
  3.  
  4. if isRecording {
  5. // 7-1. 사용자가 녹화 중간에 녹음을 종료하는 경우
  6. Log.warning?.message("Stop recording unexpectedly")
  7. recorder.stopRecording(handler: { (previewController, recordingError) in
  8. if let error = recordingError {
  9. Log.error?.message(error.localizedDescription)
  10. } else {
  11. // 현재 녹화되고 있던 내용을 모두 버립니다.
  12. recorder.discardRecording {
  13. self.timer?.invalidate()
  14. self.timer = nil
  15. self.currentLocation = 0
  16. }
  17. }
  18. })
  19. } else {
  20. // 7-2. 지도가 모두 움직인 후, 정상적으로 녹화 종료
  21. Log.info?.message("Stop recording normally")
  22. recorder.stopRecording(handler: { (previewController, recordingError) in
  23. if let error = recordingError {
  24. Log.error?.message(error.localizedDescription)
  25. } else {
  26. // 7-3. 녹화 결과를 보여주는 PreviewViewController 호출
  27. if let controller = previewController {
  28. controller.previewControllerDelegate = self
  29. self.present(controller, animated: true, completion: nil)
  30. } else {
  31. Log.warning?.message("There's no PreviewController")
  32. }
  33. }
  34. })
  35. }
  36.  
  37. // 7-4. 녹화가 종료되면 화면을 초기 상태로 돌려줍니다.
  38. barButton.title = "Start Recording"
  39. showLocationOnMap(index: 0)
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement