标签: avaudiosessioncategory

iOS 16 Beta 5 AVAudioSession setCategory 产生奇怪的错误“什么”

最近安装 iOS 16 beta 5 后,我们遇到了一个问题try AVAudioSession.sharedInstance().setCategory(<category>, options: .mixWithOthers),出现错误并失去连接。

这是错误:

AVAudioSession_iOS.mm:2365 Failed to set category, error: 'what'

没有关于此错误的其他信息。任何帮助将不胜感激。

仅供参考:这仅在 iOS Beta 5 中才开始出现,之前在 iOS Beta 4 中也曾出现过。

ios avaudiosession swift avaudiosessioncategory ios16

9
推荐指数
1
解决办法
4297
查看次数

更改音频会话类别后 MPRemoteCommandCenter 不可用

我的应用程序可以选择允许其声音与其他应用程序混合。据苹果公司称,MPRemoteCommandCenter 仅在应用程序不允许混合时可用。

在我的应用程序中,当用户点击按钮更改 mixWithOthers 设置时,音频会话也会相应设置。

但是,即使用户切换回不再允许混合,MPRemoteCommandCenter 也不会显示在锁定屏幕中,直到应用程序从缓存中删除(向上滑动)并再次启动。

有没有办法无需重新启动应用程序即可实现所需的行为?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
  UIApplication.shared.beginReceivingRemoteControlEvents()
}

var isMixWithOthersAllowed: Bool

func startProcess() {
  setAudioSession {
   setupMediaControls()
  }
}

func setAudioSession(completion: @escaping () -> Void) {
  let audioSession = AVAudioSession.sharedInstance()

  do {

    if isMixWithOthersAllowed {
      try audioSession.setCategory(.playback, options: [.mixWithOthers])
      /* The remote command center will not be available when mixing with others, 
        as stated by Apple in the docs. */
    } else {
      try …
Run Code Online (Sandbox Code Playgroud)

xcode avaudiosession swift mpremotecommandcenter avaudiosessioncategory

5
推荐指数
0
解决办法
711
查看次数