capacitor-voice-recorder-wav-stereo 7.0.5 → 7.0.6
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 +43 -22
- package/package.json +1 -1
|
@@ -106,31 +106,52 @@ public class VoiceRecorder: CAPPlugin {
|
|
|
106
106
|
let audioSession = AVAudioSession.sharedInstance()
|
|
107
107
|
var devices = [[String: Any]]()
|
|
108
108
|
|
|
109
|
-
//
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"deviceId": port.uid,
|
|
114
|
-
"kind": "audioinput", // MediaDeviceKind.audioinput
|
|
115
|
-
"label": port.portName,
|
|
116
|
-
"groupId": NSNull()
|
|
117
|
-
])
|
|
118
|
-
}
|
|
109
|
+
// 現在の設定を保持
|
|
110
|
+
let originalCategory = audioSession.category
|
|
111
|
+
let originalMode = audioSession.mode
|
|
112
|
+
var didActivate = false
|
|
119
113
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
]
|
|
114
|
+
do {
|
|
115
|
+
// セッションをアクティブ化せずにデバイス情報を取得
|
|
116
|
+
if !audioSession.isOtherAudioPlaying {
|
|
117
|
+
try audioSession.setActive(false)
|
|
118
|
+
didActivate = true
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 入力デバイス(マイクなど)
|
|
122
|
+
let availableInputs = audioSession.availableInputs ?? []
|
|
123
|
+
for port in availableInputs {
|
|
124
|
+
devices.append([
|
|
125
|
+
"deviceId": port.uid,
|
|
126
|
+
"kind": "audioinput",
|
|
127
|
+
"label": port.portName,
|
|
128
|
+
"groupId": NSNull()
|
|
129
|
+
])
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 出力デバイス(現在のルートから取得)
|
|
133
|
+
let currentOutputs = audioSession.currentRoute.outputs
|
|
134
|
+
for port in currentOutputs {
|
|
135
|
+
devices.append([
|
|
136
|
+
"deviceId": port.uid,
|
|
137
|
+
"kind": "audiooutput",
|
|
138
|
+
"label": port.portName,
|
|
139
|
+
"groupId": NSNull()
|
|
140
|
+
])
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 元の設定に戻す
|
|
144
|
+
if didActivate {
|
|
145
|
+
try audioSession.setCategory(originalCategory, mode: originalMode)
|
|
146
|
+
try audioSession.setActive(true)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
} catch {
|
|
150
|
+
call.reject("Failed to get audio devices: \(error.localizedDescription)")
|
|
151
|
+
return
|
|
129
152
|
}
|
|
130
153
|
|
|
131
|
-
call.resolve([
|
|
132
|
-
"devices": devices
|
|
133
|
-
])
|
|
154
|
+
call.resolve(["devices": devices])
|
|
134
155
|
}
|
|
135
156
|
|
|
136
157
|
func doesUserGaveAudioRecordingPermission() -> Bool {
|