mirror of
https://github.com/samsonjs/SwiftyCam.git
synced 2026-03-25 09:05:52 +00:00
Added support for no audio video recording
This commit is contained in:
parent
65c26e35a9
commit
5fcc21edf9
2 changed files with 12 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate {
|
|||
maximumVideoDuration = 10.0
|
||||
shouldUseDeviceOrientation = true
|
||||
allowAutoRotate = false
|
||||
audioEnabled = true
|
||||
|
||||
addButtons()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,6 +153,10 @@ open class SwiftyCamViewController: UIViewController {
|
|||
|
||||
/// Specifies the [videoGravity](https://developer.apple.com/reference/avfoundation/avcapturevideopreviewlayer/1386708-videogravity) for the preview layer.
|
||||
public var videoGravity : SwiftyCamVideoGravity = .resizeAspect
|
||||
|
||||
/// Sets whether or not video recordings will record audio
|
||||
/// Setting to true will prompt user for access to microphone on View Controller launch.
|
||||
public var audioEnabled = true
|
||||
|
||||
|
||||
// MARK: Public Get-only Variable Declarations
|
||||
|
|
@ -694,6 +698,9 @@ open class SwiftyCamViewController: UIViewController {
|
|||
/// Add Audio Inputs
|
||||
|
||||
fileprivate func addAudioInput() {
|
||||
guard audioEnabled == true else {
|
||||
return
|
||||
}
|
||||
do {
|
||||
let audioDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio)
|
||||
let audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice)
|
||||
|
|
@ -968,6 +975,10 @@ open class SwiftyCamViewController: UIViewController {
|
|||
guard allowBackgroundAudio == true else {
|
||||
return
|
||||
}
|
||||
|
||||
guard audioEnabled == true else {
|
||||
return
|
||||
}
|
||||
|
||||
do{
|
||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord,
|
||||
|
|
|
|||
Loading…
Reference in a new issue