mirror of
https://github.com/samsonjs/SwiftyCam.git
synced 2026-04-27 15:07:43 +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
|
maximumVideoDuration = 10.0
|
||||||
shouldUseDeviceOrientation = true
|
shouldUseDeviceOrientation = true
|
||||||
allowAutoRotate = false
|
allowAutoRotate = false
|
||||||
|
audioEnabled = true
|
||||||
|
|
||||||
addButtons()
|
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.
|
/// Specifies the [videoGravity](https://developer.apple.com/reference/avfoundation/avcapturevideopreviewlayer/1386708-videogravity) for the preview layer.
|
||||||
public var videoGravity : SwiftyCamVideoGravity = .resizeAspect
|
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
|
// MARK: Public Get-only Variable Declarations
|
||||||
|
|
@ -694,6 +698,9 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
/// Add Audio Inputs
|
/// Add Audio Inputs
|
||||||
|
|
||||||
fileprivate func addAudioInput() {
|
fileprivate func addAudioInput() {
|
||||||
|
guard audioEnabled == true else {
|
||||||
|
return
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
let audioDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio)
|
let audioDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio)
|
||||||
let audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice)
|
let audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice)
|
||||||
|
|
@ -968,6 +975,10 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
guard allowBackgroundAudio == true else {
|
guard allowBackgroundAudio == true else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guard audioEnabled == true else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
do{
|
do{
|
||||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord,
|
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue