capacitor-voice-recorder-wav-stereo 7.0.5 → 7.0.7

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.
@@ -106,31 +106,48 @@ public class VoiceRecorder: CAPPlugin {
106
106
  let audioSession = AVAudioSession.sharedInstance()
107
107
  var devices = [[String: Any]]()
108
108
 
109
- // 入力デバイス(マイクなど)
110
- let inputs = audioSession.currentRoute.inputs
111
- for port in inputs {
112
- devices.append([
113
- "deviceId": port.uid,
114
- "kind": "audioinput", // MediaDeviceKind.audioinput
115
- "label": port.portName,
116
- "groupId": NSNull()
117
- ])
118
- }
109
+ // 現在の設定をログ出力
110
+ print("Current Category: \(audioSession.category.rawValue)")
111
+ print("Current Mode: \(audioSession.mode.rawValue)")
112
+ print("Current Route: \(audioSession.currentRoute)")
113
+
114
+ // 変更前のルートを保持
115
+ let originalRoute = audioSession.currentRoute
119
116
 
120
- // 出力デバイス(スピーカーなど)
121
- let outputs = audioSession.currentRoute.outputs
122
- for port in outputs {
123
- devices.append([
124
- "deviceId": port.uid,
125
- "kind": "audiooutput", // MediaDeviceKind.audiooutput
126
- "label": port.portName,
127
- "groupId": NSNull()
128
- ])
117
+ do {
118
+ // セッションを変更せずにデバイス情報を取得
119
+ let availableInputs = audioSession.availableInputs ?? []
120
+ for port in availableInputs {
121
+ devices.append([
122
+ "deviceId": port.uid,
123
+ "kind": "audioinput",
124
+ "label": port.portName,
125
+ "groupId": NSNull()
126
+ ])
127
+ }
128
+
129
+ let currentOutputs = audioSession.currentRoute.outputs
130
+ for port in currentOutputs {
131
+ devices.append([
132
+ "deviceId": port.uid,
133
+ "kind": "audiooutput",
134
+ "label": port.portName,
135
+ "groupId": NSNull()
136
+ ])
137
+ }
138
+
139
+ // ルートが変更されたか確認
140
+ if audioSession.currentRoute != originalRoute {
141
+ print("Route changed during operation!")
142
+ print("New Route: \(audioSession.currentRoute)")
143
+ }
144
+
145
+ } catch {
146
+ call.reject("Failed to get audio devices: \(error.localizedDescription)")
147
+ return
129
148
  }
130
149
 
131
- call.resolve([
132
- "devices": devices
133
- ])
150
+ call.resolve(["devices": devices])
134
151
  }
135
152
 
136
153
  func doesUserGaveAudioRecordingPermission() -> Bool {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-voice-recorder-wav-stereo",
3
- "version": "7.0.5",
3
+ "version": "7.0.7",
4
4
  "description": "Capacitor plugin for voice recording in wav format",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",