@siteed/expo-audio-stream 1.11.1 → 1.11.2
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/CHANGELOG.md +24 -1
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +62 -19
- package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +36 -6
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +25 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,25 +8,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
## [1.11.2] - 2025-01-22
|
|
12
|
+
- resources not cleanup properly on app kill (#80) ([7d522a5](https://github.com/deeeed/expo-audio-stream/commit/7d522a531e70065b99758aa3a4c669769fdbd110))
|
|
13
|
+
|
|
11
14
|
## [1.11.1] - 2025-01-22
|
|
12
15
|
- chore: force deployment of 1.11.1
|
|
13
16
|
|
|
17
|
+
|
|
14
18
|
## [1.11.0] - 2025-01-22
|
|
15
19
|
- feat(audio): add intelligent call interruption handling & compression improvements ([f8f6187](https://github.com/deeeed/expo-audio-stream/pull/78))
|
|
16
20
|
|
|
17
21
|
|
|
22
|
+
|
|
18
23
|
## [1.10.0] - 2025-01-14
|
|
19
24
|
- add support for pausing and resuming compressed recordings ([bc3f629](https://github.com/deeeed/expo-audio-stream/commit/bc3f6295d060396325e0f008ff00b3be9c8722cd))
|
|
20
25
|
- optimize notification channel settings ([daa075e](https://github.com/deeeed/expo-audio-stream/commit/daa075e668f8faf0b8d2849e18c37384bdd293b8))
|
|
21
26
|
|
|
22
27
|
|
|
23
28
|
|
|
29
|
+
|
|
24
30
|
## [1.9.2] - 2025-01-12
|
|
25
31
|
- ios bitrate verification to prevent invalid values ([035a180](https://github.com/deeeed/expo-audio-stream/commit/035a1800833264edcc59724aaa8a2e12d5c78dc2))
|
|
26
32
|
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
|
|
36
|
+
|
|
30
37
|
## [1.9.1] - 2025-01-12
|
|
31
38
|
- ios potentially missing compressed file info ([88a628c](https://github.com/deeeed/expo-audio-stream/commit/88a628c35f2bfd626a2a5de1eb6950efd814619d))
|
|
32
39
|
|
|
@@ -34,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
34
41
|
|
|
35
42
|
|
|
36
43
|
|
|
44
|
+
|
|
37
45
|
## [1.9.0] - 2025-01-11
|
|
38
46
|
- feat(web-audio): optimize memory usage and streaming performance for web audio recording (#75) ([7b93e12](https://github.com/deeeed/expo-audio-stream/commit/7b93e12aae4bc0599b06b48ca34a60f65587fc75))
|
|
39
47
|
|
|
@@ -42,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
42
50
|
|
|
43
51
|
|
|
44
52
|
|
|
53
|
+
|
|
45
54
|
## [1.8.0] - 2025-01-10
|
|
46
55
|
- feat(audio): implement audio compression support ([ff4e060](https://github.com/deeeed/expo-audio-stream/commit/ff4e060fef1061804c1cc0126d4344d2d50daa9a))
|
|
47
56
|
|
|
@@ -51,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
51
60
|
|
|
52
61
|
|
|
53
62
|
|
|
63
|
+
|
|
54
64
|
## [1.7.2] - 2025-01-07
|
|
55
65
|
- fix(audio-stream): correct WAV header handling in web audio recording ([9ba7de5](https://github.com/deeeed/expo-audio-stream/commit/9ba7de5b96ca4cc937dea261c80d3fda9c99e8f4))
|
|
56
66
|
|
|
@@ -61,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
61
71
|
|
|
62
72
|
|
|
63
73
|
|
|
74
|
+
|
|
64
75
|
## [1.7.1] - 2025-01-07
|
|
65
76
|
- update notification to avoid triggering new alerts (#71) ([32dcfc5](https://github.com/deeeed/expo-audio-stream/commit/32dcfc55daf3236babefc17016f329c177d466fd))
|
|
66
77
|
|
|
@@ -72,6 +83,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
72
83
|
|
|
73
84
|
|
|
74
85
|
|
|
86
|
+
|
|
75
87
|
## [1.7.0] - 2025-01-05
|
|
76
88
|
- feat(playground): enhance app configuration and build setup for production deployment (#58) ([929d443](https://github.com/deeeed/expo-audio-stream/commit/929d443145378b1430d215db5c00b13758420e2b))
|
|
77
89
|
- chore(expo-audio-stream): release @siteed/expo-audio-stream@1.6.1 ([084e8ad](https://github.com/deeeed/expo-audio-stream/commit/084e8adb91da7874c9e608b55d9c7b2ffd7a8327))
|
|
@@ -89,6 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
89
101
|
|
|
90
102
|
|
|
91
103
|
|
|
104
|
+
|
|
92
105
|
## [1.6.1] - 2024-12-11
|
|
93
106
|
- chore(expo-audio-stream): remove git commit step from publish script ([4a772ce](https://github.com/deeeed/expo-audio-stream/commit/4a772ce93bb7405d9b8e981f46bdf8941a71ecfe))
|
|
94
107
|
- chore: more publishing automation ([3693021](https://github.com/deeeed/expo-audio-stream/commit/369302107f9dca9dddd8ae68e6214481a39976ac))
|
|
@@ -110,6 +123,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
110
123
|
|
|
111
124
|
|
|
112
125
|
|
|
126
|
+
|
|
113
127
|
## [1.5.0] - 2024-12-10
|
|
114
128
|
- UNPUBLISHED because of a bug in the build system
|
|
115
129
|
|
|
@@ -124,6 +138,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
124
138
|
|
|
125
139
|
|
|
126
140
|
|
|
141
|
+
|
|
127
142
|
## [1.4.0] - 2024-12-05
|
|
128
143
|
- chore: remove unusded dependencies ([ad81dd5](https://github.com/deeeed/expo-audio-stream/commit/ad81dd560c93dd1d04995a323a4ae72d4de20f3e))
|
|
129
144
|
|
|
@@ -138,6 +153,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
138
153
|
|
|
139
154
|
|
|
140
155
|
|
|
156
|
+
|
|
141
157
|
## [1.3.1] - 2024-12-05
|
|
142
158
|
- feat(web): implement throttling and optimize event processing (#49) ([da28765](https://github.com/deeeed/expo-audio-stream/commit/da2876524c2c9d6e0a980fde40a0197b929d8a7f))
|
|
143
159
|
|
|
@@ -152,6 +168,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
152
168
|
|
|
153
169
|
|
|
154
170
|
|
|
171
|
+
|
|
155
172
|
## [1.3.0] - 2024-11-28
|
|
156
173
|
### Added
|
|
157
174
|
- refactor(permissions): standardize permission status response structure across platforms (#44) ([7c9c800](https://github.com/deeeed/expo-audio-stream/commit/7c9c800d83b7cea3516643371484d5e1f3b99e4c))
|
|
@@ -171,6 +188,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
171
188
|
|
|
172
189
|
|
|
173
190
|
|
|
191
|
+
|
|
174
192
|
## [1.2.5] - 2024-11-12
|
|
175
193
|
### Added
|
|
176
194
|
- docs(license): add MIT license to all packages (6 files changed)
|
|
@@ -187,6 +205,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
187
205
|
|
|
188
206
|
|
|
189
207
|
|
|
208
|
+
|
|
190
209
|
## [1.2.4] - 2024-11-05
|
|
191
210
|
### Changed
|
|
192
211
|
- Android minimum audio interval set to 10ms.
|
|
@@ -206,6 +225,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
206
225
|
|
|
207
226
|
|
|
208
227
|
|
|
228
|
+
|
|
209
229
|
## [1.2.0] - 2024-10-24
|
|
210
230
|
### Added
|
|
211
231
|
- Feature: Keep device awake during recording with `keepAwake` option
|
|
@@ -225,6 +245,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
225
245
|
|
|
226
246
|
|
|
227
247
|
|
|
248
|
+
|
|
228
249
|
## [1.1.17] - 2024-10-21
|
|
229
250
|
### Added
|
|
230
251
|
- Support bluetooth headset on ios
|
|
@@ -241,6 +262,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
241
262
|
|
|
242
263
|
|
|
243
264
|
|
|
265
|
+
|
|
244
266
|
## [1.0.0] - 2024-04-01
|
|
245
267
|
### Added
|
|
246
268
|
- Initial release of @siteed/expo-audio-stream.
|
|
@@ -251,7 +273,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
251
273
|
- Feature: Audio features extraction during recording.
|
|
252
274
|
- Feature: Consistent WAV PCM recording format across all platforms.
|
|
253
275
|
|
|
254
|
-
[unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.11.
|
|
276
|
+
[unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.11.2...HEAD
|
|
277
|
+
[1.11.2]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.11.1...@siteed/expo-audio-stream@1.11.2
|
|
255
278
|
[1.11.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.11.0...@siteed/expo-audio-stream@1.11.1
|
|
256
279
|
[1.11.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.10.0...@siteed/expo-audio-stream@1.11.0
|
|
257
280
|
[1.10.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-stream@1.9.2...@siteed/expo-audio-stream@1.10.0
|
|
@@ -28,6 +28,7 @@ import android.media.AudioAttributes
|
|
|
28
28
|
import android.media.AudioFocusRequest
|
|
29
29
|
import android.telephony.PhoneStateListener
|
|
30
30
|
import android.telephony.TelephonyManager
|
|
31
|
+
import android.app.ActivityManager
|
|
31
32
|
|
|
32
33
|
class AudioRecorderManager(
|
|
33
34
|
private val context: Context,
|
|
@@ -137,6 +138,11 @@ class AudioRecorderManager(
|
|
|
137
138
|
).also { instance = it }
|
|
138
139
|
}
|
|
139
140
|
}
|
|
141
|
+
|
|
142
|
+
fun destroy() {
|
|
143
|
+
instance?.cleanup()
|
|
144
|
+
instance = null
|
|
145
|
+
}
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
@RequiresApi(Build.VERSION_CODES.R)
|
|
@@ -641,15 +647,28 @@ class AudioRecorderManager(
|
|
|
641
647
|
|
|
642
648
|
fun getStatus(): Bundle {
|
|
643
649
|
synchronized(audioRecordLock) {
|
|
650
|
+
// Check if service is actually running
|
|
651
|
+
val isServiceRunning = context.let { ctx ->
|
|
652
|
+
val manager = ctx.getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager
|
|
653
|
+
manager?.getRunningServices(Integer.MAX_VALUE)
|
|
654
|
+
?.any { it.service.className == AudioRecordingService::class.java.name }
|
|
655
|
+
} ?: false
|
|
656
|
+
|
|
657
|
+
// If service is running but we think we're not recording, clean up
|
|
658
|
+
if (isServiceRunning && !isRecording.get()) {
|
|
659
|
+
Log.d(Constants.TAG, "Detected orphaned recording service, cleaning up...")
|
|
660
|
+
cleanup()
|
|
661
|
+
AudioRecordingService.stopService(context)
|
|
662
|
+
}
|
|
663
|
+
|
|
644
664
|
if (!isRecording.get()) {
|
|
645
665
|
Log.d(Constants.TAG, "Not recording --- skip status with default values")
|
|
646
|
-
|
|
647
666
|
return bundleOf(
|
|
648
667
|
"isRecording" to false,
|
|
649
668
|
"isPaused" to false,
|
|
650
669
|
"mime" to mimeType,
|
|
651
670
|
"size" to 0,
|
|
652
|
-
"interval" to recordingConfig
|
|
671
|
+
"interval" to (recordingConfig?.interval ?: 0)
|
|
653
672
|
)
|
|
654
673
|
}
|
|
655
674
|
|
|
@@ -916,27 +935,51 @@ class AudioRecorderManager(
|
|
|
916
935
|
isFirstChunk = false
|
|
917
936
|
}
|
|
918
937
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
938
|
+
fun cleanup() {
|
|
939
|
+
synchronized(audioRecordLock) {
|
|
940
|
+
try {
|
|
941
|
+
if (isRecording.get()) {
|
|
942
|
+
audioRecord?.stop()
|
|
943
|
+
compressedRecorder?.stop()
|
|
944
|
+
compressedRecorder?.release()
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
isRecording.set(false)
|
|
948
|
+
isPaused.set(false)
|
|
949
|
+
|
|
950
|
+
if (recordingConfig.showNotification) {
|
|
951
|
+
notificationManager.stopUpdates()
|
|
952
|
+
AudioRecordingService.stopService(context)
|
|
953
|
+
}
|
|
925
954
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
955
|
+
releaseWakeLock()
|
|
956
|
+
releaseAudioFocus()
|
|
957
|
+
audioRecord?.release()
|
|
958
|
+
audioRecord = null
|
|
959
|
+
|
|
960
|
+
// Reset all state
|
|
961
|
+
totalRecordedTime = 0
|
|
962
|
+
pausedDuration = 0
|
|
963
|
+
lastEmittedSize = 0
|
|
964
|
+
recordingStartTime = 0
|
|
965
|
+
|
|
966
|
+
// Update the WAV header if needed
|
|
967
|
+
audioFile?.let { file ->
|
|
968
|
+
audioFileHandler.updateWavHeader(file)
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// Send event to notify that recording was stopped
|
|
972
|
+
eventSender.sendExpoEvent(Constants.RECORDING_INTERRUPTED_EVENT_NAME, bundleOf(
|
|
973
|
+
"reason" to "appKilled",
|
|
974
|
+
"isPaused" to false
|
|
975
|
+
))
|
|
976
|
+
} catch (e: Exception) {
|
|
977
|
+
Log.e(Constants.TAG, "Error during cleanup", e)
|
|
978
|
+
}
|
|
937
979
|
}
|
|
938
980
|
}
|
|
939
981
|
|
|
982
|
+
@RequiresApi(Build.VERSION_CODES.Q)
|
|
940
983
|
private fun initializeCompressedRecorder(fileExtension: String, promise: Promise): Boolean {
|
|
941
984
|
try {
|
|
942
985
|
// Use the existing audioFileHandler instance
|
|
@@ -8,6 +8,7 @@ import android.os.IBinder
|
|
|
8
8
|
import android.util.Log
|
|
9
9
|
import android.os.Handler
|
|
10
10
|
import android.os.Looper
|
|
11
|
+
import expo.modules.kotlin.Promise
|
|
11
12
|
|
|
12
13
|
class AudioRecordingService : Service() {
|
|
13
14
|
private val notificationManager by lazy {
|
|
@@ -43,17 +44,46 @@ class AudioRecordingService : Service() {
|
|
|
43
44
|
override fun onDestroy() {
|
|
44
45
|
Log.d(Constants.TAG, "AudioRecordingService onDestroy")
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
stopForeground(STOP_FOREGROUND_REMOVE)
|
|
48
|
-
} else {
|
|
49
|
-
@Suppress("DEPRECATION")
|
|
50
|
-
stopForeground(true)
|
|
51
|
-
}
|
|
47
|
+
stopForeground(STOP_FOREGROUND_REMOVE)
|
|
52
48
|
|
|
53
49
|
isRunning = false
|
|
54
50
|
super.onDestroy()
|
|
55
51
|
}
|
|
56
52
|
|
|
53
|
+
override fun onTaskRemoved(rootIntent: Intent?) {
|
|
54
|
+
super.onTaskRemoved(rootIntent)
|
|
55
|
+
Log.d(Constants.TAG, "AudioRecordingService onTaskRemoved")
|
|
56
|
+
|
|
57
|
+
// Stop recording when app is killed
|
|
58
|
+
AudioRecorderManager.getInstance()?.let { manager ->
|
|
59
|
+
mainHandler.post {
|
|
60
|
+
// Create a simple promise object for internal use
|
|
61
|
+
val promise = object : Promise {
|
|
62
|
+
override fun resolve(value: Any?) {
|
|
63
|
+
Log.d(Constants.TAG, "Successfully stopped recording on task removed")
|
|
64
|
+
cleanup()
|
|
65
|
+
}
|
|
66
|
+
override fun reject(code: String, message: String?, cause: Throwable?) {
|
|
67
|
+
Log.e(Constants.TAG, "Failed to stop recording on task removed: $message")
|
|
68
|
+
cleanup()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
manager.stopRecording(promise)
|
|
74
|
+
} catch (e: Exception) {
|
|
75
|
+
promise.reject("ERROR", e.message, e)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
private fun cleanup() {
|
|
83
|
+
stopForeground(STOP_FOREGROUND_REMOVE)
|
|
84
|
+
stopSelf()
|
|
85
|
+
}
|
|
86
|
+
|
|
57
87
|
companion object {
|
|
58
88
|
fun startService(context: Context) {
|
|
59
89
|
val serviceIntent = Intent(context, AudioRecordingService::class.java)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
package net.siteed.audiostream
|
|
2
2
|
|
|
3
3
|
import android.Manifest
|
|
4
|
+
import android.app.ActivityManager
|
|
5
|
+
import android.content.Context
|
|
4
6
|
import android.os.Build
|
|
5
7
|
import android.os.Bundle
|
|
6
8
|
import android.util.Log
|
|
@@ -171,6 +173,29 @@ class ExpoAudioStreamModule : Module(), EventSender {
|
|
|
171
173
|
)
|
|
172
174
|
}
|
|
173
175
|
}
|
|
176
|
+
|
|
177
|
+
OnDestroy {
|
|
178
|
+
AudioRecorderManager.destroy()
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Add a new function to check if recording is actually running
|
|
182
|
+
AsyncFunction("checkRecordingStatus") { promise: Promise ->
|
|
183
|
+
val isServiceRunning = AudioRecordingService::class.java.name.let { className ->
|
|
184
|
+
val manager = appContext.reactContext?.getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager
|
|
185
|
+
manager?.getRunningServices(Integer.MAX_VALUE)
|
|
186
|
+
?.any { it.service.className == className }
|
|
187
|
+
} ?: false
|
|
188
|
+
|
|
189
|
+
val status = audioRecorderManager.getStatus()
|
|
190
|
+
|
|
191
|
+
// If service is running but isRecording is false, we need to cleanup
|
|
192
|
+
if (isServiceRunning && !status.getBoolean("isRecording")) {
|
|
193
|
+
audioRecorderManager.cleanup()
|
|
194
|
+
AudioRecordingService.stopService(appContext.reactContext!!)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
promise.resolve(status)
|
|
198
|
+
}
|
|
174
199
|
}
|
|
175
200
|
|
|
176
201
|
private fun initializeManager() {
|