V
V
Vasily Penkevich2019-09-11 15:40:38
Swift
Vasily Penkevich, 2019-09-11 15:40:38

How to embed sound when recording video from a camera to alert the user?

Default camera UIImagePickerController. At the moment the video recording starts, I want to send a sound there, which signals that the video has started to be recorded

case .right:
        view.isUserInteractionEnabled = false
        recordingInfoLabel.changeTextAndAnimate(text: "Please wait")
        recordingWaitingTimerLabel.showTimer(seconds: Int(currentDuration))
       DispatchQueue.main.async {
            let play = Sound()
            play.playNotificationSound()
            print(play.audioPlayer as Any)
        }
        Timer.scheduledTimer(withTimeInterval: currentDuration, repeats: false) { (timer) in
            self.stopCaptureAndTrim()
        }

Audio playback is the most standard. Works on any empty ViewController.
func playNotificationSound() {
    guard let soundURL = Bundle.main.url(forResource: "reload4", withExtension: "wav") else { return }
    audioPlayer = AVPlayer(url: soundURL as URL)
    audioPlayer?.play()
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2019-09-11
@briahas

import AudioToolbox
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

Kinds of constants instead of kSystemSoundID_Vibrate are searched on the Internet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question