【问题标题】:swift 3 record video but not audioswift 3录制视频但不录制音频
【发布时间】:2017-01-04 12:40:35
【问题描述】:

我正在 swift 3 中使用以下内容设置相机控制器:

let cameraController = UIImagePickerController()
    cameraController.sourceType = .camera
    cameraController.mediaTypes = [kUTTypeMovie as NSString as String]
    cameraController.showsCameraControls = true
    cameraController.videoQuality = UIImagePickerControllerQualityType.typeHigh
    cameraController.allowsEditing = false
    cameraController.delegate = delegate
    present(cameraController, animated: false, completion: nil)

这会记录视频和音频,因此要求访问相机和麦克风。音频在这里一点用处都没有。

您如何录制视频,但禁用麦克风以不录制音频,并且不询问使用麦克风的权限?

【问题讨论】:

标签: ios swift ios-camera


【解决方案1】:

将您的媒体类型设置为 KUTTypeVideo 而不是 KUTTypeMovie 应该可以解决问题。

KUTTypeVideo documentation

【讨论】:

  • 我试过这个,但是它使应用程序崩溃并出现错误:*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No available types for source 1' *** First throw call stack: (0x1848011b8 0x18323855c 0x18aba07c0 0x1000fff6c 0x1000ffd08 0x1000ffd84 0x18a6ebd30 0x18a6ebcb0 0x18a6d6128 0x18a6eb59c 0x18a6eb0c4 0x18a6e6328 0x18a6b6da0 0x18aea075c 0x18ae9a130 0x1847aeb5c 0x1847ae4a4 0x1847ac0a4 0x1846da2b8 0x18618e198 0x18a7217fc 0x18a71c534 0x10011ca14 0x1836bd5b8) libc++abi.dylib: terminating with uncaught exception of type NSException
  • 您要导入 MobileCoreServices 吗?
  • 是的,我是:import UIKit import MediaPlayer import MobileCoreServices import Photos import AssetsLibrary import AVKit
猜你喜欢
  • 1970-01-01
  • 2022-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-02
  • 2014-12-15
  • 1970-01-01
  • 2012-05-08
相关资源
最近更新 更多