Browse Source

修改 AVAudioSession.CategoryOptions 切换添加 option ,beast 耳机多次使用无声音问题。

jsonwang 3 năm trước cách đây
mục cha
commit
49ba6a17dc

+ 5 - 2
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -615,8 +615,11 @@ public class BFRecordScreenController: BFBaseViewController {
 
         _ = checkStatus()
         // mdf by ak 切换外放和请求权限分开 否则会导致首次安装时不能执行切换操作
-        let options: AVAudioSession.CategoryOptions = [.defaultToSpeaker, .allowBluetooth]
-        try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: options)
+        if(AVAudioSession.sharedInstance().category != .playAndRecord){
+            let options: AVAudioSession.CategoryOptions = [.defaultToSpeaker, .allowBluetooth,.allowBluetoothA2DP]
+            try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: options)
+        }
+
 
         // add by ak 取 nsl token
         BFRecordScreenViewModel.getNlsAccessToken { [weak self] token, appkey in