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.
@@ -106,16 +106,20 @@ public class VoiceRecorder: CAPPlugin {
106
106
  let audioSession = AVAudioSession.sharedInstance()
107
107
  var devices = [[String: Any]]()
108
108
 
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
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 audioSession.currentRoute != originalRoute {
141
- print("Route changed during operation!")
142
- print("New Route: \(audioSession.currentRoute)")
143
+ // 元のカテゴリに戻す
144
+ if didChangeCategory {
145
+ try audioSession.setCategory(originalCategory, mode: originalMode)
146
+ try audioSession.setActive(true)
143
147
  }
144
148
 
145
149
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-voice-recorder-wav-stereo",
3
- "version": "7.0.7",
3
+ "version": "7.0.8",
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",