capacitor-voice-recorder-wav-stereo 7.0.7 → 7.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Plugin/VoiceRecorder.swift +16 -12
- package/package.json +1 -1
|
@@ -106,16 +106,20 @@ public class VoiceRecorder: CAPPlugin {
|
|
|
106
106
|
let audioSession = AVAudioSession.sharedInstance()
|
|
107
107
|
var devices = [[String: Any]]()
|
|
108
108
|
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// 変更前のルートを保持
|
|
115
|
-
let originalRoute = audioSession.currentRoute
|
|
109
|
+
// カテゴリ変更を防ぐためのフラグ
|
|
110
|
+
var didChangeCategory = false
|
|
111
|
+
let originalCategory = audioSession.category
|
|
112
|
+
let originalMode = audioSession.mode
|
|
116
113
|
|
|
117
114
|
do {
|
|
118
|
-
//
|
|
115
|
+
// カテゴリがPlayAndRecordの場合のみ変更
|
|
116
|
+
if audioSession.category == .playAndRecord {
|
|
117
|
+
try audioSession.setCategory(.ambient, mode: .default)
|
|
118
|
+
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
|
|
119
|
+
didChangeCategory = true
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// デバイス情報取得
|
|
119
123
|
let availableInputs = audioSession.availableInputs ?? []
|
|
120
124
|
for port in availableInputs {
|
|
121
125
|
devices.append([
|
|
@@ -136,10 +140,10 @@ public class VoiceRecorder: CAPPlugin {
|
|
|
136
140
|
])
|
|
137
141
|
}
|
|
138
142
|
|
|
139
|
-
//
|
|
140
|
-
if
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
// 元のカテゴリに戻す
|
|
144
|
+
if didChangeCategory {
|
|
145
|
+
try audioSession.setCategory(originalCategory, mode: originalMode)
|
|
146
|
+
try audioSession.setActive(true)
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
} catch {
|