AVAudioSession在另一个会话正在运行时停用

时间:2018-07-31 02:22:56

标签: ios swift audio avfoundation avaudiosession

我在Sub Button1_Click() Application.Calculation = xlCalculationManual Application.ScreenUpdating = False Const CopyDataOnly As Boolean = False Dim c As Long Dim c1 As String, c2 As String Dim source As Range, target As Range With Sheets("Validation by rules") For c = 0 To 7 c1 = Split("A,B,C,G,F,R,S,T", ",")(c) c2 = Split("A,B,C,D,E,F,G,H", ",")(c) Set source = .Range(.Cells(1, c1), .Cells(.Rows.Count, c1).End(xlUp)) Set target = Sheets("TMP").Cells(1, c2) If CopyDataOnly Then target.Resize(source.Rows.Count).Value = source.Value Else source.Copy target End If Next End With Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub 类别中运行一个音频会话,并为录音机选择了playAndRecord选项。我们称之为mixWithOthers

recordAudioSession

我还有另一个在let recordAudioSession = AudioSession() recordAudioSession.setCategory(.playAndRecord, options: [.mixWithOthers]) 类别中运行的音频会话,并且有playback选项用于播放音频流。我们称之为mixWithOthers

playAudioSession

我有一个音频正在使用AVAudioPlayer通过我的let playAudioSession= AudioSession() playAudioSession.setCategory(.playback, options: [.mixWithOthers]) 播放,同时有一个录音机正在我的playAudioSession中运行,试图记录音频。

现在,一旦音频播放完毕,我会尝试停用recordAudioSession,但让playAudioSession保持活动状态:

recordAudioSession

因此,基本上,一个会话完成了任务,我想停用它,另一个会话仍在使用中,所以我想保持它的正常运行。

但是我收到错误日志,并且记录仪被系统关闭:

audioPlayer.stop()
playAudioSession.setActive(false, options: .notifyOthersOnDeactivation)

此错误是否意味着在停用音频会话时任何音频会话都无法运行I / O,或者我使用的方式不正确?

有什么方法可以使记录器保持读取状态并停用AVAudioSession.mm:692: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running i/o. all i/o should be stopped or paused prior to deactivating the audio session.

0 个答案:

没有答案