expo-audio 1.0.14 → 1.0.15
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 +10 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/audio/AudioExceptions.kt +6 -0
- package/android/src/main/java/expo/modules/audio/AudioPlayer.kt +4 -1
- package/android/src/main/java/expo/modules/audio/AudioRecorder.kt +29 -11
- package/build/Audio.types.d.ts +1 -1
- package/build/Audio.types.d.ts.map +1 -1
- package/build/Audio.types.js.map +1 -1
- package/build/AudioModule.web.d.ts.map +1 -1
- package/build/AudioModule.web.js +16 -1
- package/build/AudioModule.web.js.map +1 -1
- package/build/ExpoAudio.web.d.ts.map +1 -1
- package/build/ExpoAudio.web.js +18 -3
- package/build/ExpoAudio.web.js.map +1 -1
- package/build/utils/options.d.ts +4 -2
- package/build/utils/options.d.ts.map +1 -1
- package/build/utils/options.js +9 -4
- package/build/utils/options.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15-sources.jar +0 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.14/expo.modules.audio-1.0.14.aar → 1.0.15/expo.modules.audio-1.0.15.aar} +0 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.14/expo.modules.audio-1.0.14.module → 1.0.15/expo.modules.audio-1.0.15.module} +22 -22
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.module.md5 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.14/expo.modules.audio-1.0.14.pom → 1.0.15/expo.modules.audio-1.0.15.pom} +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.15/expo.modules.audio-1.0.15.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha512 +1 -1
- package/package.json +2 -2
- package/src/Audio.types.ts +1 -1
- package/src/AudioModule.web.ts +21 -5
- package/src/ExpoAudio.web.ts +23 -3
- package/src/utils/options.ts +25 -6
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14-sources.jar +0 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.module.md5 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.14/expo.modules.audio-1.0.14.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.0.15 — 2025-11-21
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- [Android] Fix issue where after replacing the media source, events are emitted twice. ([#40133](https://github.com/expo/expo/pull/40133) by [@alanjhughes](https://github.com/alanjhughes))
|
|
18
|
+
- [Android] Fix issue where if `prepare` fails on android there was no error and the user would receive an empty file. ([#40239](https://github.com/expo/expo/pull/40239) by [@alanjhughes](https://github.com/alanjhughes))
|
|
19
|
+
- [Android] Fix incorrect volume read. ([#40258](https://github.com/expo/expo/pull/40258) by [@alanjhughes](https://github.com/alanjhughes))
|
|
20
|
+
- [web] Bring fix from [#38273](https://github.com/expo/expo/pull/38273) to web. ([#40802](https://github.com/expo/expo/pull/40802) by [@alanjhughes](https://github.com/alanjhughes)
|
|
21
|
+
- [Web] Fix recording options not being applied to web correctly. ([#41154](https://github.com/expo/expo/pull/41154) by [@alanjhughes](https://github.com/alanjhughes))
|
|
22
|
+
|
|
13
23
|
## 1.0.14 — 2025-10-28
|
|
14
24
|
|
|
15
25
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'expo.modules.audio'
|
|
7
|
-
version = '1.0.
|
|
7
|
+
version = '1.0.15'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.audio"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 1
|
|
13
|
-
versionName "1.0.
|
|
13
|
+
versionName "1.0.15"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
compileOptions {
|
|
@@ -16,3 +16,9 @@ internal class DeviceInfoNotFoundException :
|
|
|
16
16
|
|
|
17
17
|
internal class PreferredInputNotFoundException :
|
|
18
18
|
CodedException("Could not set preferred device input")
|
|
19
|
+
|
|
20
|
+
internal class AudioRecorderPrepareException(cause: Throwable) :
|
|
21
|
+
CodedException("Failed to prepare the AudioRecorder", cause)
|
|
22
|
+
|
|
23
|
+
internal class AudioRecorderAlreadyPreparedException :
|
|
24
|
+
CodedException("AudioRecorder has already been prepared. Stop or release the current session before preparing again.")
|
|
@@ -76,7 +76,8 @@ class AudioPlayer(
|
|
|
76
76
|
}
|
|
77
77
|
ref.volume = 0f
|
|
78
78
|
} else {
|
|
79
|
-
|
|
79
|
+
previousVolume = boundedVolume
|
|
80
|
+
ref.volume = boundedVolume
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -87,6 +88,7 @@ class AudioPlayer(
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
private fun startUpdating() {
|
|
91
|
+
updateJob?.cancel()
|
|
90
92
|
updateJob = flow {
|
|
91
93
|
while (true) {
|
|
92
94
|
emit(Unit)
|
|
@@ -240,6 +242,7 @@ class AudioPlayer(
|
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
override fun sharedObjectDidRelease() {
|
|
245
|
+
super.sharedObjectDidRelease()
|
|
243
246
|
appContext?.mainQueue?.launch {
|
|
244
247
|
playerScope.cancel()
|
|
245
248
|
visualizer?.release()
|
|
@@ -12,6 +12,7 @@ import android.media.MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED
|
|
|
12
12
|
import android.os.Build
|
|
13
13
|
import android.os.Bundle
|
|
14
14
|
import androidx.core.content.ContextCompat
|
|
15
|
+
import androidx.core.net.toUri
|
|
15
16
|
import expo.modules.kotlin.AppContext
|
|
16
17
|
import expo.modules.kotlin.sharedobjects.SharedObject
|
|
17
18
|
import kotlinx.coroutines.Job
|
|
@@ -21,7 +22,6 @@ import java.io.File
|
|
|
21
22
|
import java.io.IOException
|
|
22
23
|
import java.util.UUID
|
|
23
24
|
import kotlin.math.log10
|
|
24
|
-
import androidx.core.net.toUri
|
|
25
25
|
|
|
26
26
|
private const val RECORDING_STATUS_UPDATE = "recordingStatusUpdate"
|
|
27
27
|
|
|
@@ -44,6 +44,9 @@ class AudioRecorder(
|
|
|
44
44
|
var isPaused = false
|
|
45
45
|
private var recordingTimerJob: Job? = null
|
|
46
46
|
|
|
47
|
+
private fun currentFileUrl(): String? =
|
|
48
|
+
filePath?.let(::File)?.toUri()?.toString()
|
|
49
|
+
|
|
47
50
|
private fun getAudioRecorderLevels(): Double? {
|
|
48
51
|
if (!meteringEnabled || recorder == null || !isRecording) {
|
|
49
52
|
return null
|
|
@@ -66,14 +69,20 @@ class AudioRecorder(
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
fun prepareRecording(options: RecordingOptions?) {
|
|
69
|
-
recorder
|
|
72
|
+
if (recorder != null || isPrepared || isRecording || isPaused) {
|
|
73
|
+
throw AudioRecorderAlreadyPreparedException()
|
|
74
|
+
}
|
|
75
|
+
val recordingOptions = options ?: this.options
|
|
76
|
+
val mediaRecorder = createRecorder(recordingOptions)
|
|
77
|
+
recorder = mediaRecorder
|
|
70
78
|
try {
|
|
71
|
-
|
|
79
|
+
mediaRecorder.prepare()
|
|
72
80
|
isPrepared = true
|
|
73
|
-
} catch (
|
|
74
|
-
|
|
81
|
+
} catch (cause: Exception) {
|
|
82
|
+
mediaRecorder.release()
|
|
75
83
|
recorder = null
|
|
76
84
|
isPrepared = false
|
|
85
|
+
throw AudioRecorderPrepareException(cause)
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
|
|
@@ -125,12 +134,23 @@ class AudioRecorder(
|
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
fun stopRecording(): Bundle {
|
|
137
|
+
val url = currentFileUrl()
|
|
138
|
+
var durationMillis: Long
|
|
139
|
+
|
|
128
140
|
try {
|
|
129
141
|
recorder?.stop()
|
|
142
|
+
durationMillis = getAudioRecorderDurationMillis()
|
|
130
143
|
} finally {
|
|
131
144
|
reset()
|
|
132
145
|
}
|
|
133
146
|
|
|
147
|
+
val status = Bundle().apply {
|
|
148
|
+
putBoolean("canRecord", false)
|
|
149
|
+
putBoolean("isRecording", false)
|
|
150
|
+
putLong("durationMillis", durationMillis)
|
|
151
|
+
url?.let { putString("url", it) }
|
|
152
|
+
}
|
|
153
|
+
|
|
134
154
|
// Emit completion event on the main thread
|
|
135
155
|
appContext?.mainQueue?.launch {
|
|
136
156
|
emit(
|
|
@@ -140,12 +160,12 @@ class AudioRecorder(
|
|
|
140
160
|
"isFinished" to true,
|
|
141
161
|
"hasError" to false,
|
|
142
162
|
"error" to null,
|
|
143
|
-
"url" to
|
|
163
|
+
"url" to url
|
|
144
164
|
)
|
|
145
165
|
)
|
|
146
166
|
}
|
|
147
167
|
|
|
148
|
-
return
|
|
168
|
+
return status
|
|
149
169
|
}
|
|
150
170
|
|
|
151
171
|
private fun reset() {
|
|
@@ -229,9 +249,7 @@ class AudioRecorder(
|
|
|
229
249
|
getAudioRecorderLevels()?.let {
|
|
230
250
|
putDouble("metering", it)
|
|
231
251
|
}
|
|
232
|
-
|
|
233
|
-
putString("url", it.toUri().toString())
|
|
234
|
-
}
|
|
252
|
+
currentFileUrl()?.let { putString("url", it) }
|
|
235
253
|
}
|
|
236
254
|
} else {
|
|
237
255
|
Bundle().apply {
|
|
@@ -277,7 +295,7 @@ class AudioRecorder(
|
|
|
277
295
|
"isFinished" to true,
|
|
278
296
|
"hasError" to true,
|
|
279
297
|
"error" to null,
|
|
280
|
-
"url" to
|
|
298
|
+
"url" to currentFileUrl()
|
|
281
299
|
)
|
|
282
300
|
)
|
|
283
301
|
}
|
package/build/Audio.types.d.ts
CHAN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ACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,EAAE,mBAAmB,CAAC;IAClC;;OAEG;IACH,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;;;OAIG;IACH,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;;;;OAKG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,UAAU,GAAG,YAAY,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,YAAY,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,eAAe,GACvB,WAAW,GACX,SAAS,GACT,KAAK,GACL,eAAe,GACf,aAAa,GACb,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,CAAC"}
|
package/build/Audio.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Audio.types.js","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"","sourcesContent":["import { AudioQuality, IOSOutputFormat } from './RecordingConstants';\n\n// @docsMissing\nexport type AudioSource =\n | string\n | number\n | null\n | {\n /**\n * A string representing the resource identifier for the audio,\n * which could be an HTTPS address, a local file path, or the name of a static audio file resource.\n */\n uri?: string;\n /**\n * The asset ID of a local audio asset, acquired with the `require` function.\n * This property is exclusive with the `uri` property. When both are present, the `assetId` will be ignored.\n */\n assetId?: number;\n /**\n * An object representing the HTTP headers to send along with the request for a remote audio source.\n * On web requires the `Access-Control-Allow-Origin` header returned by the server to include the current domain.\n */\n headers?: Record<string, string>;\n };\n\n/**\n * Options for configuring audio player behavior.\n */\nexport type AudioPlayerOptions = {\n /**\n * How often (in milliseconds) to emit playback status updates. Defaults to 500ms.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer } from 'expo-audio';\n *\n * export default function App() {\n * const player = useAudioPlayer(source);\n *\n * // High-frequency updates for smooth progress bars\n * const player = useAudioPlayer(source, { updateInterval: 100 });\n *\n * // Standard updates (default behavior)\n * const player = useAudioPlayer(source, { updateInterval: 500 });\n *\n * // Low-frequency updates for better performance\n * const player = useAudioPlayer(source, { updateInterval: 1000 });\n * }\n * ```\n *\n * @default 500ms\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n updateInterval?: number;\n /**\n * If set to `true`, the system will attempt to download the resource to the device before loading.\n * This value defaults to `false`.\n *\n * Works with:\n * - Local assets from `require('path/to/file')`\n * - Remote HTTP/HTTPS URLs\n * - Asset objects\n *\n * When enabled, this ensures the audio file is fully downloaded before playback begins.\n * This can improve playback performance and reduce buffering, especially for users\n * managing multiple audio players simultaneously.\n *\n * On Android and iOS, this will download the audio file to the device's tmp directory before playback begins.\n * The system will purge the file at its discretion.\n *\n * On web, this will download the audio file to the user's device memory and make it available for the user to play.\n * The system will usually purge the file from memory after a reload or on memory pressure.\n * On web, CORS restrictions apply to the blob url, so you need to make sure the server returns the `Access-Control-Allow-Origin` header.\n *\n * @platform ios\n * @platform web\n * @platform android\n */\n downloadFirst?: boolean;\n /**\n * Determines the [cross origin policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin) used by the underlying native view on web.\n * If `undefined` (default), does not use CORS at all. If set to `'anonymous'`, the audio will be loaded with CORS enabled.\n * Note that some audio may not play if CORS is enabled, depending on the CDN settings.\n * If you encounter issues, consider adjusting the `crossOrigin` property.\n *\n *\n * @platform web\n * @default undefined\n */\n crossOrigin?: 'anonymous' | 'use-credentials';\n /**\n * If set to `true`, the audio session will not be deactivated when this player pauses or finishes playback.\n * This prevents interrupting other audio sources (like videos) when the audio ends.\n *\n * Useful for sound effects that should not interfere with ongoing video playback or other audio.\n * The audio session for this player will not be deactivated automatically when the player finishes playback.\n *\n * > **Note:** If needed, you can manually deactivate the audio session using `setIsAudioActiveAsync(false)`.\n *\n * @platform ios\n * @default false\n */\n keepAudioSessionActive?: boolean;\n};\n\n/**\n * @deprecated Use `AudioPlayerOptions` instead.\n * Options for audio loading behavior.\n */\nexport type AudioLoadOptions = AudioPlayerOptions;\n\n/**\n * Represents an available audio input device for recording.\n *\n * This type describes audio input sources like built-in microphones, external microphones,\n * or other audio input devices that can be used for recording. Each input has an identifying\n * information that can be used to select the preferred recording source.\n */\nexport type RecordingInput = {\n /** Human-readable name of the audio input device. */\n name: string;\n /** Type or category of the input device (for example, 'Built-in Microphone', 'External Microphone'). */\n type: string;\n /** Unique identifier for the input device, used to select the input ('Built-in Microphone', 'External Microphone') for recording. */\n uid: string;\n};\n\n/**\n * Pitch correction quality settings for audio playback rate changes.\n *\n * When changing playback rate, pitch correction can be applied to maintain the original pitch.\n * Different quality levels offer trade-offs between processing power and audio quality.\n *\n * @platform ios\n */\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\n/**\n * Comprehensive status information for an `AudioPlayer`.\n *\n * This object contains all the current state information about audio playback,\n * including playback position, duration, loading state, and playback settings.\n * Used by `useAudioPlayerStatus()` to provide real-time status updates.\n */\nexport type AudioStatus = {\n /** Unique identifier for the player instance. */\n id: number;\n /** Current playback position in seconds. */\n currentTime: number;\n /** String representation of the player's internal playback state. */\n playbackState: string;\n /** String representation of the player's time control status (playing/paused/waiting). */\n timeControlStatus: string;\n /** Reason why the player is waiting to play (if applicable). */\n reasonForWaitingToPlay: string;\n /** Whether the player is currently muted. */\n mute: boolean;\n /** Total duration of the audio in seconds, or 0 if not yet determined. */\n duration: number;\n /** Whether the audio is currently playing. */\n playing: boolean;\n /** Whether the audio is set to loop when it reaches the end. */\n loop: boolean;\n /** Whether the audio just finished playing. */\n didJustFinish: boolean;\n /** Whether the player is currently buffering data. */\n isBuffering: boolean;\n /** Whether the audio has finished loading and is ready to play. */\n isLoaded: boolean;\n /** Current playback rate (1.0 = normal speed). */\n playbackRate: number;\n /** Whether pitch correction is enabled for rate changes. */\n shouldCorrectPitch: boolean;\n};\n\n/**\n * Status information for recording operations from the event system.\n *\n * This type represents the status data emitted by `recordingStatusUpdate` events.\n * It contains high-level information about the recording session and any errors.\n * Used internally by the event system. Most users should use `useAudioRecorderState()` instead.\n */\nexport type RecordingStatus = {\n /** Unique identifier for the recording session. */\n id: number;\n /** Whether the recording has finished (stopped). */\n isFinished: boolean;\n /** Whether an error occurred during recording. */\n hasError: boolean;\n /** Error message if an error occurred, `null` otherwise. */\n error: string | null;\n /** File URL of the completed recording, if available. */\n url: string | null;\n};\n\n/**\n * Current state information for an `AudioRecorder`.\n *\n * This object contains detailed information about the recorder's current state,\n * including recording status, duration, and technical details. This is what you get\n * when calling `recorder.getStatus()` or using `useAudioRecorderState()`.\n */\nexport type RecorderState = {\n /** Whether the recorder is ready and able to record. */\n canRecord: boolean;\n /** Whether recording is currently in progress. */\n isRecording: boolean;\n /** Duration of the current recording in milliseconds. */\n durationMillis: number;\n /** Whether the media services have been reset (typically indicates a system interruption). */\n mediaServicesDidReset: boolean;\n /** Current audio level/volume being recorded (if metering is enabled). */\n metering?: number;\n /** File URL where the recording will be saved, if available. */\n url: string | null;\n};\n\n/**\n * Audio output format options for Android recording.\n *\n * Specifies the container format for recorded audio files on Android.\n * Different formats have different compatibility and compression characteristics.\n *\n * @platform android\n */\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\n/**\n * Audio encoder options for Android recording.\n *\n * Specifies the audio codec used to encode recorded audio on Android.\n * Different encoders offer different quality, compression, and compatibility trade-offs.\n *\n * @platform android\n */\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\n/**\n * Bit rate strategies for audio encoding.\n *\n * Determines how the encoder manages bit rate during recording, affecting\n * file size consistency and quality characteristics.\n */\nexport type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';\n\n/**\n * Options for controlling how audio recording is started.\n */\nexport type RecordingStartOptions = {\n /**\n * The duration in seconds after which recording should automatically stop.\n * If not provided, recording continues until manually stopped.\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n forDuration?: number;\n /**\n * The time in seconds to wait before starting the recording.\n * If not provided, recording starts immediately.\n *\n * **Platform behavior:**\n * - Android: Ignored, recording starts immediately\n * - iOS: Uses native AVAudioRecorder.record(atTime:) for precise timing.\n * - Web: Ignored, recording starts immediately\n *\n * > **warning** On iOS, the recording process starts immediately (you'll see status updates),\n * but actual audio capture begins after the specified delay. This is not a countdown, since\n * the recorder is active but silent during the delay period.\n *\n * @platform ios\n */\n atTime?: number;\n};\n\nexport type RecordingOptions = {\n /**\n * A boolean that determines whether audio level information will be part of the status object under the \"metering\" key.\n */\n isMeteringEnabled?: boolean;\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate: number;\n /**\n * The desired number of channels.\n *\n * @example 2\n */\n numberOfChannels: number;\n /**\n * The desired bit rate.\n *\n * @example 128000\n */\n bitRate: number;\n /**\n * Recording options for the Android platform.\n * @platform android\n */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n * @platform ios\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n * @platform web\n */\n web?: RecordingOptionsWeb;\n};\n\n/**\n * Recording options for the web.\n *\n * Web recording uses the `MediaRecorder` API, which has different capabilities\n * compared to native platforms. These options map directly to `MediaRecorder` settings.\n *\n * @platform web\n */\nexport type RecordingOptionsWeb = {\n /** MIME type for the recording (for example, 'audio/webm', 'audio/mp4'). */\n mimeType?: string;\n /** Target bits per second for the recording. */\n bitsPerSecond?: number;\n};\n\n/**\n * Recording configuration options specific to iOS.\n *\n * iOS recording uses `AVAudioRecorder` with extensive format and quality options.\n * These settings provide fine-grained control over the recording characteristics.\n *\n * @platform ios\n */\nexport type RecordingOptionsIos = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.\n */\n outputFormat?: string | IOSOutputFormat | number;\n /**\n * The desired audio quality. See the [`AudioQuality`](#audioquality) enum for all valid values.\n */\n audioQuality: AudioQuality | number;\n /**\n * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.\n */\n bitRateStrategy?: number;\n /**\n * The desired bit depth hint.\n *\n * @example 16\n */\n bitDepthHint?: number;\n /**\n * The desired PCM bit depth.\n *\n * @example 16\n */\n linearPCMBitDepth?: number;\n /**\n * A boolean describing if the PCM data should be formatted in big endian.\n */\n linearPCMIsBigEndian?: boolean;\n /**\n * A boolean describing if the PCM data should be encoded in floating point or integral values.\n */\n linearPCMIsFloat?: boolean;\n};\n\n/**\n * Recording configuration options specific to Android.\n *\n * Android recording uses `MediaRecorder` with options for format, encoder, and file constraints.\n * These settings control the output format and quality characteristics.\n *\n * @platform android\n */\nexport type RecordingOptionsAndroid = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.\n */\n outputFormat: AndroidOutputFormat;\n /**\n * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.\n */\n audioEncoder: AndroidAudioEncoder;\n /**\n * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still\n * be called after this point).\n *\n * @example\n * `65536`\n */\n maxFileSize?: number;\n /**\n * The desired audio Source. See the [`AndroidAudioSource`](#androidaudiosource) enum for all valid values.\n */\n audioSource?: RecordingSource;\n};\n\nexport type AudioMode = {\n /**\n * Determines if audio playback is allowed when the device is in silent mode.\n *\n * @platform ios\n */\n playsInSilentMode: boolean;\n /**\n * Determines how the audio session interacts with other sessions.\n *\n * @platform ios\n */\n interruptionMode: InterruptionMode;\n /**\n * Determines how the audio session interacts with other sessions on Android.\n *\n * @platform android\n */\n interruptionModeAndroid: InterruptionModeAndroid;\n /**\n * Whether the audio session allows recording.\n *\n * @default false\n * @platform ios\n */\n allowsRecording: boolean;\n /**\n * Whether the audio session stays active when the app moves to the background.\n * @default false\n */\n shouldPlayInBackground: boolean;\n /**\n * Whether the audio should route through the earpiece.\n * @platform android\n */\n shouldRouteThroughEarpiece: boolean;\n};\n\n/**\n * Audio interruption behavior modes for iOS.\n *\n * Controls how your app's audio interacts with other apps' audio when interruptions occur.\n * This affects what happens when phone calls, notifications, or other apps play audio.\n *\n * @platform ios\n */\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n\n/**\n * Audio interruption behavior modes for Android.\n *\n * Controls how your app's audio interacts with other apps' audio on Android.\n * Note that Android doesn't support 'mixWithOthers' mode; audio focus is more strictly managed.\n *\n * @platform android\n */\nexport type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';\n\n/**\n * Recording source for android.\n *\n * An audio source defines both a default physical source of audio signal, and a recording configuration.\n *\n * - `camcorder`: Microphone audio source tuned for video recording, with the same orientation as the camera if available.\n * - `default`: The default audio source.\n * - `mic`: Microphone audio source.\n * - `unprocessed`: Microphone audio source tuned for unprocessed (raw) sound if available, behaves like `default` otherwise.\n * - `voice_communication`: Microphone audio source tuned for voice communications such as VoIP. It will for instance take advantage of echo cancellation or automatic gain control if available.\n * - `voice_performance`: Source for capturing audio meant to be processed in real time and played back for live performance (e.g karaoke). The capture path will minimize latency and coupling with playback path.\n * - `voice_recognition`: Microphone audio source tuned for voice recognition.\n *\n * @see https://developer.android.com/reference/android/media/MediaRecorder.AudioSource\n * @platform android\n */\nexport type RecordingSource =\n | 'camcorder'\n | 'default'\n | 'mic'\n | 'remote_submix'\n | 'unprocessed'\n | 'voice_communication'\n | 'voice_performance'\n | 'voice_recognition';\n"]}
|
|
1
|
+
{"version":3,"file":"Audio.types.js","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"","sourcesContent":["import { AudioQuality, IOSOutputFormat } from './RecordingConstants';\n\n// @docsMissing\nexport type AudioSource =\n | string\n | number\n | null\n | {\n /**\n * A string representing the resource identifier for the audio,\n * which could be an HTTPS address, a local file path, or the name of a static audio file resource.\n */\n uri?: string;\n /**\n * The asset ID of a local audio asset, acquired with the `require` function.\n * This property is exclusive with the `uri` property. When both are present, the `assetId` will be ignored.\n */\n assetId?: number;\n /**\n * An object representing the HTTP headers to send along with the request for a remote audio source.\n * On web requires the `Access-Control-Allow-Origin` header returned by the server to include the current domain.\n */\n headers?: Record<string, string>;\n };\n\n/**\n * Options for configuring audio player behavior.\n */\nexport type AudioPlayerOptions = {\n /**\n * How often (in milliseconds) to emit playback status updates. Defaults to 500ms.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer } from 'expo-audio';\n *\n * export default function App() {\n * const player = useAudioPlayer(source);\n *\n * // High-frequency updates for smooth progress bars\n * const player = useAudioPlayer(source, { updateInterval: 100 });\n *\n * // Standard updates (default behavior)\n * const player = useAudioPlayer(source, { updateInterval: 500 });\n *\n * // Low-frequency updates for better performance\n * const player = useAudioPlayer(source, { updateInterval: 1000 });\n * }\n * ```\n *\n * @default 500ms\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n updateInterval?: number;\n /**\n * If set to `true`, the system will attempt to download the resource to the device before loading.\n * This value defaults to `false`.\n *\n * Works with:\n * - Local assets from `require('path/to/file')`\n * - Remote HTTP/HTTPS URLs\n * - Asset objects\n *\n * When enabled, this ensures the audio file is fully downloaded before playback begins.\n * This can improve playback performance and reduce buffering, especially for users\n * managing multiple audio players simultaneously.\n *\n * On Android and iOS, this will download the audio file to the device's tmp directory before playback begins.\n * The system will purge the file at its discretion.\n *\n * On web, this will download the audio file to the user's device memory and make it available for the user to play.\n * The system will usually purge the file from memory after a reload or on memory pressure.\n * On web, CORS restrictions apply to the blob url, so you need to make sure the server returns the `Access-Control-Allow-Origin` header.\n *\n * @platform ios\n * @platform web\n * @platform android\n */\n downloadFirst?: boolean;\n /**\n * Determines the [cross origin policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin) used by the underlying native view on web.\n * If `undefined` (default), does not use CORS at all. If set to `'anonymous'`, the audio will be loaded with CORS enabled.\n * Note that some audio may not play if CORS is enabled, depending on the CDN settings.\n * If you encounter issues, consider adjusting the `crossOrigin` property.\n *\n *\n * @platform web\n * @default undefined\n */\n crossOrigin?: 'anonymous' | 'use-credentials';\n /**\n * If set to `true`, the audio session will not be deactivated when this player pauses or finishes playback.\n * This prevents interrupting other audio sources (like videos) when the audio ends.\n *\n * Useful for sound effects that should not interfere with ongoing video playback or other audio.\n * The audio session for this player will not be deactivated automatically when the player finishes playback.\n *\n * > **Note:** If needed, you can manually deactivate the audio session using `setIsAudioActiveAsync(false)`.\n *\n * @platform ios\n * @default false\n */\n keepAudioSessionActive?: boolean;\n};\n\n/**\n * @deprecated Use `AudioPlayerOptions` instead.\n * Options for audio loading behavior.\n */\nexport type AudioLoadOptions = AudioPlayerOptions;\n\n/**\n * Represents an available audio input device for recording.\n *\n * This type describes audio input sources like built-in microphones, external microphones,\n * or other audio input devices that can be used for recording. Each input has an identifying\n * information that can be used to select the preferred recording source.\n */\nexport type RecordingInput = {\n /** Human-readable name of the audio input device. */\n name: string;\n /** Type or category of the input device (for example, 'Built-in Microphone', 'External Microphone'). */\n type: string;\n /** Unique identifier for the input device, used to select the input ('Built-in Microphone', 'External Microphone') for recording. */\n uid: string;\n};\n\n/**\n * Pitch correction quality settings for audio playback rate changes.\n *\n * When changing playback rate, pitch correction can be applied to maintain the original pitch.\n * Different quality levels offer trade-offs between processing power and audio quality.\n *\n * @platform ios\n */\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\n/**\n * Comprehensive status information for an `AudioPlayer`.\n *\n * This object contains all the current state information about audio playback,\n * including playback position, duration, loading state, and playback settings.\n * Used by `useAudioPlayerStatus()` to provide real-time status updates.\n */\nexport type AudioStatus = {\n /** Unique identifier for the player instance. */\n id: number;\n /** Current playback position in seconds. */\n currentTime: number;\n /** String representation of the player's internal playback state. */\n playbackState: string;\n /** String representation of the player's time control status (playing/paused/waiting). */\n timeControlStatus: string;\n /** Reason why the player is waiting to play (if applicable). */\n reasonForWaitingToPlay: string;\n /** Whether the player is currently muted. */\n mute: boolean;\n /** Total duration of the audio in seconds, or 0 if not yet determined. */\n duration: number;\n /** Whether the audio is currently playing. */\n playing: boolean;\n /** Whether the audio is set to loop when it reaches the end. */\n loop: boolean;\n /** Whether the audio just finished playing. */\n didJustFinish: boolean;\n /** Whether the player is currently buffering data. */\n isBuffering: boolean;\n /** Whether the audio has finished loading and is ready to play. */\n isLoaded: boolean;\n /** Current playback rate (1.0 = normal speed). */\n playbackRate: number;\n /** Whether pitch correction is enabled for rate changes. */\n shouldCorrectPitch: boolean;\n};\n\n/**\n * Status information for recording operations from the event system.\n *\n * This type represents the status data emitted by `recordingStatusUpdate` events.\n * It contains high-level information about the recording session and any errors.\n * Used internally by the event system. Most users should use `useAudioRecorderState()` instead.\n */\nexport type RecordingStatus = {\n /** Unique identifier for the recording session. */\n id: number;\n /** Whether the recording has finished (stopped). */\n isFinished: boolean;\n /** Whether an error occurred during recording. */\n hasError: boolean;\n /** Error message if an error occurred, `null` otherwise. */\n error: string | null;\n /** File URL of the completed recording, if available. */\n url: string | null;\n};\n\n/**\n * Current state information for an `AudioRecorder`.\n *\n * This object contains detailed information about the recorder's current state,\n * including recording status, duration, and technical details. This is what you get\n * when calling `recorder.getStatus()` or using `useAudioRecorderState()`.\n */\nexport type RecorderState = {\n /** Whether the recorder is ready and able to record. */\n canRecord: boolean;\n /** Whether recording is currently in progress. */\n isRecording: boolean;\n /** Duration of the current recording in milliseconds. */\n durationMillis: number;\n /** Whether the media services have been reset (typically indicates a system interruption). */\n mediaServicesDidReset: boolean;\n /** Current audio level/volume being recorded (if metering is enabled). */\n metering?: number;\n /** File URL where the recording will be saved, if available. */\n url: string | null;\n};\n\n/**\n * Audio output format options for Android recording.\n *\n * Specifies the container format for recorded audio files on Android.\n * Different formats have different compatibility and compression characteristics.\n *\n * @platform android\n */\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\n/**\n * Audio encoder options for Android recording.\n *\n * Specifies the audio codec used to encode recorded audio on Android.\n * Different encoders offer different quality, compression, and compatibility trade-offs.\n *\n * @platform android\n */\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\n/**\n * Bit rate strategies for audio encoding.\n *\n * Determines how the encoder manages bit rate during recording, affecting\n * file size consistency and quality characteristics.\n */\nexport type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';\n\n/**\n * Options for controlling how audio recording is started.\n */\nexport type RecordingStartOptions = {\n /**\n * The duration in seconds after which recording should automatically stop.\n * If not provided, recording continues until manually stopped.\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n forDuration?: number;\n /**\n * The time in seconds to wait before starting the recording.\n * If not provided, recording starts immediately.\n *\n * **Platform behavior:**\n * - Android: Ignored, recording starts immediately\n * - iOS: Uses native AVAudioRecorder.record(atTime:) for precise timing.\n * - Web: Ignored, recording starts immediately\n *\n * > **warning** On iOS, the recording process starts immediately (you'll see status updates),\n * but actual audio capture begins after the specified delay. This is not a countdown, since\n * the recorder is active but silent during the delay period.\n *\n * @platform ios\n */\n atTime?: number;\n};\n\nexport type RecordingOptions = {\n /**\n * A boolean that determines whether audio level information will be part of the status object under the \"metering\" key.\n */\n isMeteringEnabled?: boolean;\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate: number;\n /**\n * The desired number of channels.\n *\n * @example 2\n */\n numberOfChannels: number;\n /**\n * The desired bit rate.\n *\n * @example 128000\n */\n bitRate: number;\n /**\n * Recording options for the Android platform.\n * @platform android\n */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n * @platform ios\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n * @platform web\n */\n web: RecordingOptionsWeb;\n};\n\n/**\n * Recording options for the web.\n *\n * Web recording uses the `MediaRecorder` API, which has different capabilities\n * compared to native platforms. These options map directly to `MediaRecorder` settings.\n *\n * @platform web\n */\nexport type RecordingOptionsWeb = {\n /** MIME type for the recording (for example, 'audio/webm', 'audio/mp4'). */\n mimeType?: string;\n /** Target bits per second for the recording. */\n bitsPerSecond?: number;\n};\n\n/**\n * Recording configuration options specific to iOS.\n *\n * iOS recording uses `AVAudioRecorder` with extensive format and quality options.\n * These settings provide fine-grained control over the recording characteristics.\n *\n * @platform ios\n */\nexport type RecordingOptionsIos = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.\n */\n outputFormat?: string | IOSOutputFormat | number;\n /**\n * The desired audio quality. See the [`AudioQuality`](#audioquality) enum for all valid values.\n */\n audioQuality: AudioQuality | number;\n /**\n * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.\n */\n bitRateStrategy?: number;\n /**\n * The desired bit depth hint.\n *\n * @example 16\n */\n bitDepthHint?: number;\n /**\n * The desired PCM bit depth.\n *\n * @example 16\n */\n linearPCMBitDepth?: number;\n /**\n * A boolean describing if the PCM data should be formatted in big endian.\n */\n linearPCMIsBigEndian?: boolean;\n /**\n * A boolean describing if the PCM data should be encoded in floating point or integral values.\n */\n linearPCMIsFloat?: boolean;\n};\n\n/**\n * Recording configuration options specific to Android.\n *\n * Android recording uses `MediaRecorder` with options for format, encoder, and file constraints.\n * These settings control the output format and quality characteristics.\n *\n * @platform android\n */\nexport type RecordingOptionsAndroid = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.\n */\n outputFormat: AndroidOutputFormat;\n /**\n * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.\n */\n audioEncoder: AndroidAudioEncoder;\n /**\n * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still\n * be called after this point).\n *\n * @example\n * `65536`\n */\n maxFileSize?: number;\n /**\n * The desired audio Source. See the [`AndroidAudioSource`](#androidaudiosource) enum for all valid values.\n */\n audioSource?: RecordingSource;\n};\n\nexport type AudioMode = {\n /**\n * Determines if audio playback is allowed when the device is in silent mode.\n *\n * @platform ios\n */\n playsInSilentMode: boolean;\n /**\n * Determines how the audio session interacts with other sessions.\n *\n * @platform ios\n */\n interruptionMode: InterruptionMode;\n /**\n * Determines how the audio session interacts with other sessions on Android.\n *\n * @platform android\n */\n interruptionModeAndroid: InterruptionModeAndroid;\n /**\n * Whether the audio session allows recording.\n *\n * @default false\n * @platform ios\n */\n allowsRecording: boolean;\n /**\n * Whether the audio session stays active when the app moves to the background.\n * @default false\n */\n shouldPlayInBackground: boolean;\n /**\n * Whether the audio should route through the earpiece.\n * @platform android\n */\n shouldRouteThroughEarpiece: boolean;\n};\n\n/**\n * Audio interruption behavior modes for iOS.\n *\n * Controls how your app's audio interacts with other apps' audio when interruptions occur.\n * This affects what happens when phone calls, notifications, or other apps play audio.\n *\n * @platform ios\n */\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n\n/**\n * Audio interruption behavior modes for Android.\n *\n * Controls how your app's audio interacts with other apps' audio on Android.\n * Note that Android doesn't support 'mixWithOthers' mode; audio focus is more strictly managed.\n *\n * @platform android\n */\nexport type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';\n\n/**\n * Recording source for android.\n *\n * An audio source defines both a default physical source of audio signal, and a recording configuration.\n *\n * - `camcorder`: Microphone audio source tuned for video recording, with the same orientation as the camera if available.\n * - `default`: The default audio source.\n * - `mic`: Microphone audio source.\n * - `unprocessed`: Microphone audio source tuned for unprocessed (raw) sound if available, behaves like `default` otherwise.\n * - `voice_communication`: Microphone audio source tuned for voice communications such as VoIP. It will for instance take advantage of echo cancellation or automatic gain control if available.\n * - `voice_performance`: Source for capturing audio meant to be processed in real time and played back for live performance (e.g karaoke). The capture path will minimize latency and coupling with playback path.\n * - `voice_recognition`: Microphone audio source tuned for voice recognition.\n *\n * @see https://developer.android.com/reference/android/media/MediaRecorder.AudioSource\n * @platform android\n */\nexport type RecordingSource =\n | 'camcorder'\n | 'default'\n | 'mic'\n | 'remote_submix'\n | 'unprocessed'\n | 'voice_communication'\n | 'voice_performance'\n | 'voice_recognition';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioModule.web.d.ts","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,C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AC;IAQpC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C,SAAS,IAAI,aAAa;IAW1B,KAAK,IAAI,IAAI;IAUb,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAE7B,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B3B,aAAa;YAIC,mBAAmB;IAyDjC,OAAO,CAAC,8BAA8B;CAOvC;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,SAAS,iBAAI;AAC3D,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,OAAO,iBAAI;AAE/D,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAoBhF;AAED,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAkBpF"}
|
package/build/AudioModule.web.js
CHANGED
|
@@ -348,7 +348,22 @@ export class AudioRecorderWeb extends globalThis.expo.SharedObject {
|
|
|
348
348
|
this.mediaRecorderUptimeOfLastStartResume = 0;
|
|
349
349
|
this.currentTime = 0;
|
|
350
350
|
const stream = await getUserMedia({ audio: true });
|
|
351
|
-
const
|
|
351
|
+
const defaults = RecordingPresets.HIGH_QUALITY.web;
|
|
352
|
+
const mediaRecorderOptions = {};
|
|
353
|
+
const mimeType = options.mimeType ?? defaults.mimeType;
|
|
354
|
+
if (mimeType && MediaRecorder.isTypeSupported(mimeType)) {
|
|
355
|
+
mediaRecorderOptions.mimeType = mimeType;
|
|
356
|
+
}
|
|
357
|
+
if (options.bitsPerSecond) {
|
|
358
|
+
mediaRecorderOptions.bitsPerSecond = options.bitsPerSecond;
|
|
359
|
+
}
|
|
360
|
+
else if (options.bitRate) {
|
|
361
|
+
mediaRecorderOptions.audioBitsPerSecond = options.bitRate;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
mediaRecorderOptions.bitsPerSecond = defaults.bitsPerSecond;
|
|
365
|
+
}
|
|
366
|
+
const mediaRecorder = new MediaRecorder(stream, mediaRecorderOptions);
|
|
352
367
|
mediaRecorder.addEventListener('pause', () => {
|
|
353
368
|
this.currentTime = this.getAudioRecorderDurationMillis();
|
|
354
369
|
this.mediaRecorderIsRecording = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioModule.web.js","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAazE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;IACnB,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;AACpB,CAAC,CAAC,EAAE,CAAC;AAEL,KAAK,UAAU,2BAA2B,CACxC,IAAwC;IAExC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAEtF,IAAI,CAAC;QACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,gBAAgB,CAAC,OAAO,CAAC;YAClC,KAAK,QAAQ;gBACX,OAAO,gBAAgB,CAAC,MAAM,CAAC;YACjC;gBACE,OAAO,gBAAgB,CAAC,YAAY,CAAC;QACzC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0IA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SACd,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { Asset } from 'expo-asset';\nimport { PermissionResponse, PermissionStatus } from 'expo-modules-core';\n\nimport {\n AudioMode,\n AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n RecordingStartOptions,\n} from './Audio.types';\nimport { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './AudioEventKeys';\nimport { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';\nimport { RecordingPresets } from './RecordingConstants';\n\nconst nextId = (() => {\n let id = 0;\n return () => id++;\n})();\n\nasync function getPermissionWithQueryAsync(\n name: PermissionNameWithAdditionalValues\n): Promise<PermissionStatus | null> {\n if (!navigator || !navigator.permissions || !navigator.permissions.query) return null;\n\n try {\n const { state } = await navigator.permissions.query({ name });\n switch (state) {\n case 'granted':\n return PermissionStatus.GRANTED;\n case 'denied':\n return PermissionStatus.DENIED;\n default:\n return PermissionStatus.UNDETERMINED;\n }\n } catch {\n // Firefox - TypeError: 'microphone' (value of 'name' member of PermissionDescriptor) is not a valid value for enumeration PermissionName.\n return PermissionStatus.UNDETERMINED;\n }\n}\n\nfunction getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream> {\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n return navigator.mediaDevices.getUserMedia(constraints);\n }\n\n // Some browsers partially implement mediaDevices. We can't just assign an object\n // with getUserMedia as it would overwrite existing properties.\n // Here, we will just add the getUserMedia property if it's missing.\n\n // First get ahold of the legacy getUserMedia, if present\n const getUserMedia =\n // TODO: this method is deprecated, migrate to https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n function () {\n const error: any = new Error('Permission unimplemented');\n error.code = 0;\n error.name = 'NotAllowedError';\n throw error;\n };\n\n return new Promise((resolve, reject) => {\n // TODO(@kitten): The types indicates that this is incorrect.\n // Please check whether this is correct!\n // @ts-expect-error: The `successCallback` doesn't match a `resolve` function\n getUserMedia.call(navigator, constraints, resolve, reject);\n });\n}\n\nfunction getStatusFromMedia(media: HTMLMediaElement, id: number): AudioStatus {\n const isPlaying = !!(\n media.currentTime > 0 &&\n !media.paused &&\n !media.ended &&\n media.readyState > 2\n );\n\n const status: AudioStatus = {\n id,\n isLoaded: true,\n duration: media.duration,\n currentTime: media.currentTime,\n playbackState: '',\n timeControlStatus: isPlaying ? 'playing' : 'paused',\n reasonForWaitingToPlay: '',\n playing: isPlaying,\n didJustFinish: media.ended,\n isBuffering: false,\n playbackRate: media.playbackRate,\n shouldCorrectPitch: false,\n mute: media.muted,\n loop: media.loop,\n };\n\n return status;\n}\n\nexport class AudioPlayerWeb\n extends globalThis.expo.SharedObject<AudioEvents>\n implements AudioPlayer\n{\n constructor(source: AudioSource, options: AudioPlayerOptions = {}) {\n super();\n const { updateInterval = 500, crossOrigin } = options;\n this.src = source;\n this.interval = Math.max(updateInterval, 1);\n this.crossOrigin = crossOrigin;\n this.media = this._createMediaElement();\n }\n\n id: number = nextId();\n isAudioSamplingSupported = false;\n isBuffering = false;\n shouldCorrectPitch = false;\n\n private src: AudioSource = null;\n private media: HTMLAudioElement;\n private interval = 500;\n private isPlaying = false;\n private loaded = false;\n private crossOrigin?: 'anonymous' | 'use-credentials';\n\n get playing(): boolean {\n return this.isPlaying;\n }\n\n get muted(): boolean {\n return this.media.muted;\n }\n\n set muted(value: boolean) {\n this.media.muted = value;\n }\n\n get loop(): boolean {\n return this.media.loop;\n }\n\n set loop(value: boolean) {\n this.media.loop = value;\n }\n\n get duration(): number {\n return this.media.duration;\n }\n\n get currentTime(): number {\n return this.media.currentTime;\n }\n\n get paused(): boolean {\n return this.media.paused;\n }\n\n get isLoaded(): boolean {\n return this.loaded;\n }\n\n get playbackRate(): number {\n return this.media.playbackRate;\n }\n\n set playbackRate(value: number) {\n this.media.playbackRate = value;\n }\n\n get volume(): number {\n return this.media.volume;\n }\n\n set volume(value: number) {\n this.media.volume = value;\n }\n\n get currentStatus(): AudioStatus {\n return getStatusFromMedia(this.media, this.id);\n }\n\n play(): void {\n this.media.play();\n this.isPlaying = true;\n }\n\n pause(): void {\n this.media.pause();\n this.isPlaying = false;\n }\n\n replace(source: AudioSource): void {\n const wasPlaying = this.isPlaying;\n\n // we need to remove the current media element and create a new one\n this.remove();\n\n this.src = source;\n this.isPlaying = false;\n this.loaded = false;\n this.media = this._createMediaElement();\n\n // Resume playback if it was playing before\n if (wasPlaying) {\n this.play();\n }\n }\n\n async seekTo(\n seconds: number,\n toleranceMillisBefore?: number,\n toleranceMillisAfter?: number\n ): Promise<void> {\n this.media.currentTime = seconds;\n }\n\n // Not supported on web\n setAudioSamplingEnabled(enabled: boolean): void {\n this.isAudioSamplingSupported = false;\n }\n\n setPlaybackRate(second: number, pitchCorrectionQuality?: PitchCorrectionQuality): void {\n this.media.playbackRate = second;\n this.shouldCorrectPitch = pitchCorrectionQuality === 'high';\n this.media.preservesPitch = this.shouldCorrectPitch;\n }\n\n remove(): void {\n this.media.pause();\n this.media.removeAttribute('src');\n this.media.load();\n getStatusFromMedia(this.media, this.id);\n }\n\n _createMediaElement() {\n const newSource = getSourceUri(this.src);\n const media = new Audio(newSource);\n if (this.crossOrigin !== undefined) {\n media.crossOrigin = this.crossOrigin;\n }\n\n let lastEmitTime = 0;\n const intervalSec = this.interval / 1000;\n\n // Throttled status updates based on interval\n media.ontimeupdate = () => {\n const now = media.currentTime;\n // Handle backwards time (loop/seek)\n if (now < lastEmitTime) {\n lastEmitTime = now;\n }\n if (now - lastEmitTime >= intervalSec) {\n lastEmitTime = now;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n }\n };\n\n media.onplay = () => {\n this.isPlaying = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onpause = () => {\n this.isPlaying = false;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onseeked = () => {\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n };\n\n media.onended = () => {\n lastEmitTime = 0;\n };\n\n media.onloadeddata = () => {\n this.loaded = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n isLoaded: this.loaded,\n });\n };\n\n return media;\n }\n}\n\nfunction getSourceUri(source: AudioSource): string | undefined {\n if (typeof source === 'string') {\n return source;\n }\n if (typeof source === 'number') {\n const asset = Asset.fromModule(source);\n return asset.uri;\n }\n if (typeof source?.assetId === 'number' && !source?.uri) {\n const asset = Asset.fromModule(source.assetId);\n return asset.uri;\n }\n\n return source?.uri ?? undefined;\n}\n\nexport class AudioRecorderWeb\n extends globalThis.expo.SharedObject<RecordingEvents>\n implements AudioRecorder\n{\n constructor(options: Partial<RecordingOptions>) {\n super();\n this.options = options;\n }\n\n async setup() {\n this.mediaRecorder = await this.createMediaRecorder(this.options);\n }\n\n id = nextId();\n currentTime = 0;\n uri: string | null = null;\n\n private options: Partial<RecordingOptions>;\n private mediaRecorder: MediaRecorder | null = null;\n private mediaRecorderUptimeOfLastStartResume = 0;\n private mediaRecorderIsRecording = false;\n private timeoutIds: number[] = [];\n\n get isRecording(): boolean {\n return this.mediaRecorder?.state === 'recording';\n }\n\n record(options?: RecordingStartOptions): void {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n // Clear any existing timeouts\n this.clearTimeouts();\n\n // Note: atTime is not supported on Web (no native equivalent), so we ignore it entirely\n // Only forDuration is implemented using setTimeout\n const { forDuration } = options || {};\n\n this.startActualRecording();\n\n if (forDuration !== undefined) {\n this.timeoutIds.push(\n setTimeout(() => {\n this.stop();\n }, forDuration * 1000)\n );\n }\n }\n\n private startActualRecording(): void {\n if (this.mediaRecorder?.state === 'paused') {\n this.mediaRecorder.resume();\n } else {\n this.mediaRecorder?.start();\n }\n }\n\n getAvailableInputs(): RecordingInput[] {\n return [];\n }\n\n getCurrentInput(): Promise<RecordingInput> {\n return Promise.resolve({\n type: 'Default',\n name: 'Default',\n uid: 'Default',\n });\n }\n\n async prepareToRecordAsync(): Promise<void> {\n return this.setup();\n }\n\n getStatus(): RecorderState {\n return {\n canRecord:\n this.mediaRecorder?.state === 'recording' || this.mediaRecorder?.state === 'inactive',\n isRecording: this.mediaRecorder?.state === 'recording',\n durationMillis: this.getAudioRecorderDurationMillis(),\n mediaServicesDidReset: false,\n url: this.uri,\n };\n }\n\n pause(): void {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n this.mediaRecorder?.pause();\n }\n\n recordForDuration(seconds: number): void {\n this.record({ forDuration: seconds });\n }\n\n setInput(input: string): void {}\n\n startRecordingAtTime(seconds: number): void {\n this.record({ atTime: seconds });\n }\n\n async stop(): Promise<void> {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n const dataPromise = new Promise<Blob>((resolve) =>\n this.mediaRecorder?.addEventListener('dataavailable', (e) => resolve(e.data))\n );\n\n this.mediaRecorder?.stop();\n this.mediaRecorder = null;\n\n const data = await dataPromise;\n const url = URL.createObjectURL(data);\n\n this.uri = url;\n\n this.emit(RECORDING_STATUS_UPDATE, {\n id: this.id,\n isFinished: true,\n hasError: false,\n error: null,\n url,\n });\n }\n\n clearTimeouts() {\n this.timeoutIds.forEach((id) => clearTimeout(id));\n }\n\n private async createMediaRecorder(options: Partial<RecordingOptions>): Promise<MediaRecorder> {\n if (typeof navigator !== 'undefined' && !navigator.mediaDevices) {\n throw new Error('No media devices available');\n }\n\n this.mediaRecorderUptimeOfLastStartResume = 0;\n this.currentTime = 0;\n\n const stream = await getUserMedia({ audio: true });\n\n const mediaRecorder = new (window as any).MediaRecorder(\n stream,\n options?.web || RecordingPresets.HIGH_QUALITY.web\n );\n\n mediaRecorder.addEventListener('pause', () => {\n this.currentTime = this.getAudioRecorderDurationMillis();\n this.mediaRecorderIsRecording = false;\n });\n\n mediaRecorder.addEventListener('resume', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder.addEventListener('start', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.currentTime = 0;\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder?.addEventListener('stop', () => {\n this.currentTime = 0;\n this.mediaRecorderIsRecording = false;\n\n // Clears recording icon in Chrome tab\n stream.getTracks().forEach((track) => track.stop());\n });\n\n return mediaRecorder;\n }\n\n private getAudioRecorderDurationMillis() {\n let duration = this.currentTime;\n if (this.mediaRecorderIsRecording && this.mediaRecorderUptimeOfLastStartResume > 0) {\n duration += Date.now() - this.mediaRecorderUptimeOfLastStartResume;\n }\n return duration;\n }\n}\n\nexport async function setAudioModeAsync(mode: AudioMode) {}\nexport async function setIsAudioActiveAsync(active: boolean) {}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n const maybeStatus = await getPermissionWithQueryAsync('microphone');\n switch (maybeStatus) {\n case PermissionStatus.GRANTED:\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n case PermissionStatus.DENIED:\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n default:\n return await requestRecordingPermissionsAsync();\n }\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n try {\n const stream = await getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch {\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AudioModule.web.js","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAczE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;IACnB,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;AACpB,CAAC,CAAC,EAAE,CAAC;AAEL,KAAK,UAAU,2BAA2B,CACxC,IAAwC;IAExC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAEtF,IAAI,CAAC;QACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,gBAAgB,CAAC,OAAO,CAAC;YAClC,KAAK,QAAQ;gBACX,OAAO,gBAAgB,CAA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AO;gBAChB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,KAAK,gBAAgB,CAAC,MAAM;YAC1B,OAAO;gBACL,MAAM,EAAE,gBAAgB,CAAC,MAAM;gBAC/B,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE,KAAK;aACf,CAAC;QACJ;YACE,OAAO,MAAM,gCAAgC,EAAE,CAAC;IACpD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,OAAO;YAChC,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { Asset } from 'expo-asset';\nimport { PermissionResponse, PermissionStatus } from 'expo-modules-core';\n\nimport {\n AudioMode,\n AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n RecordingOptionsWeb,\n RecordingStartOptions,\n} from './Audio.types';\nimport { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './AudioEventKeys';\nimport { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';\nimport { RecordingPresets } from './RecordingConstants';\n\nconst nextId = (() => {\n let id = 0;\n return () => id++;\n})();\n\nasync function getPermissionWithQueryAsync(\n name: PermissionNameWithAdditionalValues\n): Promise<PermissionStatus | null> {\n if (!navigator || !navigator.permissions || !navigator.permissions.query) return null;\n\n try {\n const { state } = await navigator.permissions.query({ name });\n switch (state) {\n case 'granted':\n return PermissionStatus.GRANTED;\n case 'denied':\n return PermissionStatus.DENIED;\n default:\n return PermissionStatus.UNDETERMINED;\n }\n } catch {\n // Firefox - TypeError: 'microphone' (value of 'name' member of PermissionDescriptor) is not a valid value for enumeration PermissionName.\n return PermissionStatus.UNDETERMINED;\n }\n}\n\nfunction getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream> {\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n return navigator.mediaDevices.getUserMedia(constraints);\n }\n\n // Some browsers partially implement mediaDevices. We can't just assign an object\n // with getUserMedia as it would overwrite existing properties.\n // Here, we will just add the getUserMedia property if it's missing.\n\n // First get ahold of the legacy getUserMedia, if present\n const getUserMedia =\n // TODO: this method is deprecated, migrate to https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n function () {\n const error: any = new Error('Permission unimplemented');\n error.code = 0;\n error.name = 'NotAllowedError';\n throw error;\n };\n\n return new Promise((resolve, reject) => {\n // TODO(@kitten): The types indicates that this is incorrect.\n // Please check whether this is correct!\n // @ts-expect-error: The `successCallback` doesn't match a `resolve` function\n getUserMedia.call(navigator, constraints, resolve, reject);\n });\n}\n\nfunction getStatusFromMedia(media: HTMLMediaElement, id: number): AudioStatus {\n const isPlaying = !!(\n media.currentTime > 0 &&\n !media.paused &&\n !media.ended &&\n media.readyState > 2\n );\n\n const status: AudioStatus = {\n id,\n isLoaded: true,\n duration: media.duration,\n currentTime: media.currentTime,\n playbackState: '',\n timeControlStatus: isPlaying ? 'playing' : 'paused',\n reasonForWaitingToPlay: '',\n playing: isPlaying,\n didJustFinish: media.ended,\n isBuffering: false,\n playbackRate: media.playbackRate,\n shouldCorrectPitch: false,\n mute: media.muted,\n loop: media.loop,\n };\n\n return status;\n}\n\nexport class AudioPlayerWeb\n extends globalThis.expo.SharedObject<AudioEvents>\n implements AudioPlayer\n{\n constructor(source: AudioSource, options: AudioPlayerOptions = {}) {\n super();\n const { updateInterval = 500, crossOrigin } = options;\n this.src = source;\n this.interval = Math.max(updateInterval, 1);\n this.crossOrigin = crossOrigin;\n this.media = this._createMediaElement();\n }\n\n id: number = nextId();\n isAudioSamplingSupported = false;\n isBuffering = false;\n shouldCorrectPitch = false;\n\n private src: AudioSource = null;\n private media: HTMLAudioElement;\n private interval = 500;\n private isPlaying = false;\n private loaded = false;\n private crossOrigin?: 'anonymous' | 'use-credentials';\n\n get playing(): boolean {\n return this.isPlaying;\n }\n\n get muted(): boolean {\n return this.media.muted;\n }\n\n set muted(value: boolean) {\n this.media.muted = value;\n }\n\n get loop(): boolean {\n return this.media.loop;\n }\n\n set loop(value: boolean) {\n this.media.loop = value;\n }\n\n get duration(): number {\n return this.media.duration;\n }\n\n get currentTime(): number {\n return this.media.currentTime;\n }\n\n get paused(): boolean {\n return this.media.paused;\n }\n\n get isLoaded(): boolean {\n return this.loaded;\n }\n\n get playbackRate(): number {\n return this.media.playbackRate;\n }\n\n set playbackRate(value: number) {\n this.media.playbackRate = value;\n }\n\n get volume(): number {\n return this.media.volume;\n }\n\n set volume(value: number) {\n this.media.volume = value;\n }\n\n get currentStatus(): AudioStatus {\n return getStatusFromMedia(this.media, this.id);\n }\n\n play(): void {\n this.media.play();\n this.isPlaying = true;\n }\n\n pause(): void {\n this.media.pause();\n this.isPlaying = false;\n }\n\n replace(source: AudioSource): void {\n const wasPlaying = this.isPlaying;\n\n // we need to remove the current media element and create a new one\n this.remove();\n\n this.src = source;\n this.isPlaying = false;\n this.loaded = false;\n this.media = this._createMediaElement();\n\n // Resume playback if it was playing before\n if (wasPlaying) {\n this.play();\n }\n }\n\n async seekTo(\n seconds: number,\n toleranceMillisBefore?: number,\n toleranceMillisAfter?: number\n ): Promise<void> {\n this.media.currentTime = seconds;\n }\n\n // Not supported on web\n setAudioSamplingEnabled(enabled: boolean): void {\n this.isAudioSamplingSupported = false;\n }\n\n setPlaybackRate(second: number, pitchCorrectionQuality?: PitchCorrectionQuality): void {\n this.media.playbackRate = second;\n this.shouldCorrectPitch = pitchCorrectionQuality === 'high';\n this.media.preservesPitch = this.shouldCorrectPitch;\n }\n\n remove(): void {\n this.media.pause();\n this.media.removeAttribute('src');\n this.media.load();\n getStatusFromMedia(this.media, this.id);\n }\n\n _createMediaElement() {\n const newSource = getSourceUri(this.src);\n const media = new Audio(newSource);\n if (this.crossOrigin !== undefined) {\n media.crossOrigin = this.crossOrigin;\n }\n\n let lastEmitTime = 0;\n const intervalSec = this.interval / 1000;\n\n // Throttled status updates based on interval\n media.ontimeupdate = () => {\n const now = media.currentTime;\n // Handle backwards time (loop/seek)\n if (now < lastEmitTime) {\n lastEmitTime = now;\n }\n if (now - lastEmitTime >= intervalSec) {\n lastEmitTime = now;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n }\n };\n\n media.onplay = () => {\n this.isPlaying = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onpause = () => {\n this.isPlaying = false;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onseeked = () => {\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n };\n\n media.onended = () => {\n lastEmitTime = 0;\n };\n\n media.onloadeddata = () => {\n this.loaded = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n isLoaded: this.loaded,\n });\n };\n\n return media;\n }\n}\n\nfunction getSourceUri(source: AudioSource): string | undefined {\n if (typeof source === 'string') {\n return source;\n }\n if (typeof source === 'number') {\n const asset = Asset.fromModule(source);\n return asset.uri;\n }\n if (typeof source?.assetId === 'number' && !source?.uri) {\n const asset = Asset.fromModule(source.assetId);\n return asset.uri;\n }\n\n return source?.uri ?? undefined;\n}\n\nexport class AudioRecorderWeb\n extends globalThis.expo.SharedObject<RecordingEvents>\n implements AudioRecorder\n{\n constructor(options: Partial<RecordingOptions>) {\n super();\n this.options = options;\n }\n\n async setup() {\n this.mediaRecorder = await this.createMediaRecorder(this.options);\n }\n\n id = nextId();\n currentTime = 0;\n uri: string | null = null;\n\n private options: Partial<RecordingOptions>;\n private mediaRecorder: MediaRecorder | null = null;\n private mediaRecorderUptimeOfLastStartResume = 0;\n private mediaRecorderIsRecording = false;\n private timeoutIds: number[] = [];\n\n get isRecording(): boolean {\n return this.mediaRecorder?.state === 'recording';\n }\n\n record(options?: RecordingStartOptions): void {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n // Clear any existing timeouts\n this.clearTimeouts();\n\n // Note: atTime is not supported on Web (no native equivalent), so we ignore it entirely\n // Only forDuration is implemented using setTimeout\n const { forDuration } = options || {};\n\n this.startActualRecording();\n\n if (forDuration !== undefined) {\n this.timeoutIds.push(\n setTimeout(() => {\n this.stop();\n }, forDuration * 1000)\n );\n }\n }\n\n private startActualRecording(): void {\n if (this.mediaRecorder?.state === 'paused') {\n this.mediaRecorder.resume();\n } else {\n this.mediaRecorder?.start();\n }\n }\n\n getAvailableInputs(): RecordingInput[] {\n return [];\n }\n\n getCurrentInput(): Promise<RecordingInput> {\n return Promise.resolve({\n type: 'Default',\n name: 'Default',\n uid: 'Default',\n });\n }\n\n async prepareToRecordAsync(): Promise<void> {\n return this.setup();\n }\n\n getStatus(): RecorderState {\n return {\n canRecord:\n this.mediaRecorder?.state === 'recording' || this.mediaRecorder?.state === 'inactive',\n isRecording: this.mediaRecorder?.state === 'recording',\n durationMillis: this.getAudioRecorderDurationMillis(),\n mediaServicesDidReset: false,\n url: this.uri,\n };\n }\n\n pause(): void {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n this.mediaRecorder?.pause();\n }\n\n recordForDuration(seconds: number): void {\n this.record({ forDuration: seconds });\n }\n\n setInput(input: string): void {}\n\n startRecordingAtTime(seconds: number): void {\n this.record({ atTime: seconds });\n }\n\n async stop(): Promise<void> {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n const dataPromise = new Promise<Blob>((resolve) =>\n this.mediaRecorder?.addEventListener('dataavailable', (e) => resolve(e.data))\n );\n\n this.mediaRecorder?.stop();\n this.mediaRecorder = null;\n\n const data = await dataPromise;\n const url = URL.createObjectURL(data);\n\n this.uri = url;\n\n this.emit(RECORDING_STATUS_UPDATE, {\n id: this.id,\n isFinished: true,\n hasError: false,\n error: null,\n url,\n });\n }\n\n clearTimeouts() {\n this.timeoutIds.forEach((id) => clearTimeout(id));\n }\n\n private async createMediaRecorder(\n options: Partial<RecordingOptions> & Partial<RecordingOptionsWeb>\n ): Promise<MediaRecorder> {\n if (typeof navigator !== 'undefined' && !navigator.mediaDevices) {\n throw new Error('No media devices available');\n }\n\n this.mediaRecorderUptimeOfLastStartResume = 0;\n this.currentTime = 0;\n\n const stream = await getUserMedia({ audio: true });\n\n const defaults = RecordingPresets.HIGH_QUALITY.web;\n const mediaRecorderOptions: MediaRecorderOptions = {};\n\n const mimeType = options.mimeType ?? defaults.mimeType;\n if (mimeType && MediaRecorder.isTypeSupported(mimeType)) {\n mediaRecorderOptions.mimeType = mimeType;\n }\n\n if (options.bitsPerSecond) {\n mediaRecorderOptions.bitsPerSecond = options.bitsPerSecond;\n } else if (options.bitRate) {\n mediaRecorderOptions.audioBitsPerSecond = options.bitRate;\n } else {\n mediaRecorderOptions.bitsPerSecond = defaults.bitsPerSecond;\n }\n\n const mediaRecorder = new MediaRecorder(stream, mediaRecorderOptions);\n\n mediaRecorder.addEventListener('pause', () => {\n this.currentTime = this.getAudioRecorderDurationMillis();\n this.mediaRecorderIsRecording = false;\n });\n\n mediaRecorder.addEventListener('resume', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder.addEventListener('start', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.currentTime = 0;\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder?.addEventListener('stop', () => {\n this.currentTime = 0;\n this.mediaRecorderIsRecording = false;\n\n // Clears recording icon in Chrome tab\n stream.getTracks().forEach((track) => track.stop());\n });\n\n return mediaRecorder;\n }\n\n private getAudioRecorderDurationMillis() {\n let duration = this.currentTime;\n if (this.mediaRecorderIsRecording && this.mediaRecorderUptimeOfLastStartResume > 0) {\n duration += Date.now() - this.mediaRecorderUptimeOfLastStartResume;\n }\n return duration;\n }\n}\n\nexport async function setAudioModeAsync(mode: AudioMode) {}\nexport async function setIsAudioActiveAsync(active: boolean) {}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n const maybeStatus = await getPermissionWithQueryAsync('microphone');\n switch (maybeStatus) {\n case PermissionStatus.GRANTED:\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n case PermissionStatus.DENIED:\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n default:\n return await requestRecordingPermissionsAsync();\n }\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n try {\n const stream = await getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch {\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudio.web.d.ts","sourceRoot":"","sources":["../src/ExpoAudio.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,eAAe,EAChB,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAWjD,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW,EACnD,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAoCb;AAED,wBAAgB,cAAc,CAC5B,MAAM,GAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW,EACnD,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAAC,cAAc,CAgE5B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,cAAc,GAAG,WAAW,CAGpF;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,CAAC,cAAc,EAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,QAUtC;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GACjD,WAAW,CAAC,gBAAgB,CAiB9B;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,GA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,CAAC,IAAI,CAAC,CAEtE;AAED,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEpF;AAED,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEhF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/build/ExpoAudio.web.js
CHANGED
|
@@ -126,10 +126,25 @@ export function useAudioRecorder(options, statusListener) {
|
|
|
126
126
|
export function useAudioRecorderState(recorder, interval = 500) {
|
|
127
127
|
const [state, setState] = useState(recorder.getStatus());
|
|
128
128
|
useEffect(() => {
|
|
129
|
-
const
|
|
130
|
-
|
|
129
|
+
const int = setInterval(() => {
|
|
130
|
+
const newState = recorder.getStatus();
|
|
131
|
+
setState((prevState) => {
|
|
132
|
+
const meteringChanged = (prevState.metering === undefined) !== (newState.metering === undefined) ||
|
|
133
|
+
(prevState.metering !== undefined &&
|
|
134
|
+
newState.metering !== undefined &&
|
|
135
|
+
Math.abs(prevState.metering - newState.metering) > 0.1);
|
|
136
|
+
if (prevState.canRecord !== newState.canRecord ||
|
|
137
|
+
prevState.isRecording !== newState.isRecording ||
|
|
138
|
+
prevState.mediaServicesDidReset !== newState.mediaServicesDidReset ||
|
|
139
|
+
prevState.url !== newState.url ||
|
|
140
|
+
Math.abs(prevState.durationMillis - newState.durationMillis) > 50 ||
|
|
141
|
+
meteringChanged) {
|
|
142
|
+
return newState;
|
|
143
|
+
}
|
|
144
|
+
return prevState;
|
|
145
|
+
});
|
|
131
146
|
}, interval);
|
|
132
|
-
return () => clearInterval(
|
|
147
|
+
return () => clearInterval(int);
|
|
133
148
|
}, [recorder.id]);
|
|
134
149
|
return state;
|
|
135
150
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudio.web.js","sourceRoot":"","sources":["../src/ExpoAudio.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,SAAS,E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AAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAuB,EAAE,WAAmB,GAAG;IACnF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IAExE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE;YAC1B,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QACjC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAEb,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAe;IACzD,OAAO,MAAM,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAe;IACrD,OAAO,MAAM,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,MAAM,WAAW,CAAC,gCAAgC,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,OAAO,MAAM,WAAW,CAAC,4BAA4B,EAAE,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { useEvent } from 'expo';\nimport { PermissionResponse } from 'expo-modules-core';\nimport { useEffect, useState, useMemo } from 'react';\n\nimport {\n AudioMode,\n AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n RecorderState,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\nimport {\n AUDIO_SAMPLE_UPDATE,\n PLAYBACK_STATUS_UPDATE,\n RECORDING_STATUS_UPDATE,\n} from './AudioEventKeys';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport * as AudioModule from './AudioModule.web';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource, resolveSourceWithDownload } from './utils/resolveSource';\n\n// Global registry for cleaning up object URLs when players are garbage collected\n// Since we are using blob urls, we need to clean them up when the player is garbage collected\n// this is only used for createAudioPlayer, as we have lifecycle management in useAudioPlayer\nconst objectUrlRegistry = new FinalizationRegistry((objectUrl: string) => {\n URL.revokeObjectURL(objectUrl);\n});\n\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be replaced once the source is downloaded.\n // If downloadFirst is false, we resolve the source here.\n const initialSource = downloadFirst ? null : resolveSource(source);\n const player = new AudioModule.AudioPlayerWeb(initialSource, options);\n\n // we call .replace() on the player to replace the source with the downloaded one\n // only relevant if downloadFirst is true and source is not null\n if (downloadFirst && source) {\n resolveSourceWithDownload(source)\n .then((resolved) => {\n if (resolved) {\n // Register object URL for automatic cleanup when player is garbage collected\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrlRegistry.register(player, resolved.uri);\n }\n player.replace(resolved);\n }\n })\n .catch((error) => {\n console.warn('expo-audio: Failed to download source, using fallback:', error);\n const fallback = resolveSource(source);\n if (fallback) {\n player.replace(fallback);\n }\n });\n }\n\n return player;\n}\n\nexport function useAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioModule.AudioPlayerWeb {\n const { downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.\n // If downloadFirst is false, we resolve the source here.\n // we call .replace() in the useEffect below to replace the source with the downloaded one.\n const initialSource = useMemo(() => {\n return downloadFirst ? null : resolveSource(source);\n }, [JSON.stringify(source), downloadFirst]);\n\n const player = useMemo(\n () => new AudioModule.AudioPlayerWeb(initialSource, options),\n [JSON.stringify(initialSource), JSON.stringify(options)]\n );\n\n // Handle async source resolution for downloadFirst\n useEffect(() => {\n if (!downloadFirst || source === null) {\n return;\n }\n\n let isCancelled = false;\n let objectUrl: string | null = null;\n\n // We resolve the source with expo-asset and replace the player's source with the downloaded one.\n async function resolveAndReplaceSource() {\n try {\n const resolved = await resolveSourceWithDownload(source);\n if (\n !isCancelled &&\n resolved &&\n JSON.stringify(resolved) !== JSON.stringify(initialSource)\n ) {\n // Track the object URL for cleanup\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrl = resolved.uri;\n }\n player.replace(resolved);\n }\n } catch (error) {\n if (!isCancelled) {\n console.warn('expo-audio: Failed to download source, using original:', error);\n }\n }\n }\n\n resolveAndReplaceSource();\n\n return () => {\n isCancelled = true;\n player.remove();\n // Revoke the object URL created by this hook instance\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n }\n };\n }, [player, JSON.stringify(source), downloadFirst]);\n\n return player;\n}\n\nexport function useAudioPlayerStatus(player: AudioModule.AudioPlayerWeb): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\nexport function useAudioSampleListener(\n player: AudioModule.AudioPlayerWeb,\n listener: (data: AudioSample) => void\n) {\n player.setAudioSamplingEnabled(true);\n useEffect(() => {\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => {\n player.setAudioSamplingEnabled(false);\n subscription.remove();\n };\n }, [player.id]);\n}\n\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioModule.AudioRecorderWeb {\n const platformOptions = createRecordingOptions(options);\n const recorder = useMemo(() => {\n return new AudioModule.AudioRecorderWeb(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => {\n recorder.clearTimeouts();\n subscription.remove();\n };\n }, [recorder.id]);\n\n return recorder;\n}\n\nexport function useAudioRecorderState(recorder: AudioRecorder, interval: number = 500) {\n const [state, setState] = useState<RecorderState>(recorder.getStatus());\n\n useEffect(() => {\n const id = setInterval(() => {\n setState(recorder.getStatus());\n }, interval);\n\n return () => clearInterval(id);\n }, [recorder.id]);\n\n return state;\n}\n\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\nexport async function setAudioModeAsync(mode: AudioMode): Promise<void> {\n return await AudioModule.setAudioModeAsync(mode);\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoAudio.web.js","sourceRoot":"","sources":["../src/ExpoAudio.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAWrD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEjF,iFAAiF;AACjF,8FAA8F;AAC9F,6FAA6F;AAC7F,MAAM,iBAAiB,GAAG,IAAI,oBAAoB,CAAC,CAAC,SAAiB,EAAE,EAAE;IACvE,GAAG,C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D,OAAO,MAAM,WAAW,CAAC,4BAA4B,EAAE,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { useEvent } from 'expo';\nimport { PermissionResponse } from 'expo-modules-core';\nimport { useEffect, useState, useMemo } from 'react';\n\nimport {\n AudioMode,\n AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n RecorderState,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\nimport {\n AUDIO_SAMPLE_UPDATE,\n PLAYBACK_STATUS_UPDATE,\n RECORDING_STATUS_UPDATE,\n} from './AudioEventKeys';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport * as AudioModule from './AudioModule.web';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource, resolveSourceWithDownload } from './utils/resolveSource';\n\n// Global registry for cleaning up object URLs when players are garbage collected\n// Since we are using blob urls, we need to clean them up when the player is garbage collected\n// this is only used for createAudioPlayer, as we have lifecycle management in useAudioPlayer\nconst objectUrlRegistry = new FinalizationRegistry((objectUrl: string) => {\n URL.revokeObjectURL(objectUrl);\n});\n\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be replaced once the source is downloaded.\n // If downloadFirst is false, we resolve the source here.\n const initialSource = downloadFirst ? null : resolveSource(source);\n const player = new AudioModule.AudioPlayerWeb(initialSource, options);\n\n // we call .replace() on the player to replace the source with the downloaded one\n // only relevant if downloadFirst is true and source is not null\n if (downloadFirst && source) {\n resolveSourceWithDownload(source)\n .then((resolved) => {\n if (resolved) {\n // Register object URL for automatic cleanup when player is garbage collected\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrlRegistry.register(player, resolved.uri);\n }\n player.replace(resolved);\n }\n })\n .catch((error) => {\n console.warn('expo-audio: Failed to download source, using fallback:', error);\n const fallback = resolveSource(source);\n if (fallback) {\n player.replace(fallback);\n }\n });\n }\n\n return player;\n}\n\nexport function useAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioModule.AudioPlayerWeb {\n const { downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.\n // If downloadFirst is false, we resolve the source here.\n // we call .replace() in the useEffect below to replace the source with the downloaded one.\n const initialSource = useMemo(() => {\n return downloadFirst ? null : resolveSource(source);\n }, [JSON.stringify(source), downloadFirst]);\n\n const player = useMemo(\n () => new AudioModule.AudioPlayerWeb(initialSource, options),\n [JSON.stringify(initialSource), JSON.stringify(options)]\n );\n\n // Handle async source resolution for downloadFirst\n useEffect(() => {\n if (!downloadFirst || source === null) {\n return;\n }\n\n let isCancelled = false;\n let objectUrl: string | null = null;\n\n // We resolve the source with expo-asset and replace the player's source with the downloaded one.\n async function resolveAndReplaceSource() {\n try {\n const resolved = await resolveSourceWithDownload(source);\n if (\n !isCancelled &&\n resolved &&\n JSON.stringify(resolved) !== JSON.stringify(initialSource)\n ) {\n // Track the object URL for cleanup\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrl = resolved.uri;\n }\n player.replace(resolved);\n }\n } catch (error) {\n if (!isCancelled) {\n console.warn('expo-audio: Failed to download source, using original:', error);\n }\n }\n }\n\n resolveAndReplaceSource();\n\n return () => {\n isCancelled = true;\n player.remove();\n // Revoke the object URL created by this hook instance\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n }\n };\n }, [player, JSON.stringify(source), downloadFirst]);\n\n return player;\n}\n\nexport function useAudioPlayerStatus(player: AudioModule.AudioPlayerWeb): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\nexport function useAudioSampleListener(\n player: AudioModule.AudioPlayerWeb,\n listener: (data: AudioSample) => void\n) {\n player.setAudioSamplingEnabled(true);\n useEffect(() => {\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => {\n player.setAudioSamplingEnabled(false);\n subscription.remove();\n };\n }, [player.id]);\n}\n\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioModule.AudioRecorderWeb {\n const platformOptions = createRecordingOptions(options);\n const recorder = useMemo(() => {\n return new AudioModule.AudioRecorderWeb(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => {\n recorder.clearTimeouts();\n subscription.remove();\n };\n }, [recorder.id]);\n\n return recorder;\n}\n\nexport function useAudioRecorderState(recorder: AudioRecorder, interval: number = 500) {\n const [state, setState] = useState<RecorderState>(recorder.getStatus());\n\n useEffect(() => {\n const int = setInterval(() => {\n const newState = recorder.getStatus();\n\n setState((prevState) => {\n const meteringChanged =\n (prevState.metering === undefined) !== (newState.metering === undefined) ||\n (prevState.metering !== undefined &&\n newState.metering !== undefined &&\n Math.abs(prevState.metering - newState.metering) > 0.1);\n\n if (\n prevState.canRecord !== newState.canRecord ||\n prevState.isRecording !== newState.isRecording ||\n prevState.mediaServicesDidReset !== newState.mediaServicesDidReset ||\n prevState.url !== newState.url ||\n Math.abs(prevState.durationMillis - newState.durationMillis) > 50 ||\n meteringChanged\n ) {\n return newState;\n }\n return prevState;\n });\n }, interval);\n\n return () => clearInterval(int);\n }, [recorder.id]);\n\n return state;\n}\n\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\nexport async function setAudioModeAsync(mode: AudioMode): Promise<void> {\n return await AudioModule.setAudioModeAsync(mode);\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
|
package/build/utils/options.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { RecordingOptions } from '../Audio.types';
|
|
2
|
-
|
|
1
|
+
import { RecordingOptions, RecordingOptionsAndroid, RecordingOptionsIos, RecordingOptionsWeb } from '../Audio.types';
|
|
2
|
+
type CommonRecordingOptions = {
|
|
3
3
|
extension: string;
|
|
4
4
|
sampleRate: number;
|
|
5
5
|
numberOfChannels: number;
|
|
6
6
|
bitRate: number;
|
|
7
7
|
isMeteringEnabled: boolean;
|
|
8
8
|
};
|
|
9
|
+
export declare function createRecordingOptions(options: RecordingOptions): CommonRecordingOptions & (RecordingOptionsIos | RecordingOptionsAndroid | RecordingOptionsWeb);
|
|
10
|
+
export {};
|
|
9
11
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,GACxB,sBAAsB,GAAG,CAAC,mBAAmB,GAAG,uBAAuB,GAAG,mBAAmB,CAAC,CAyBhG"}
|
package/build/utils/options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Platform } from 'expo-modules-core';
|
|
2
2
|
export function createRecordingOptions(options) {
|
|
3
|
-
|
|
3
|
+
const commonOptions = {
|
|
4
4
|
extension: options.extension,
|
|
5
5
|
sampleRate: options.sampleRate,
|
|
6
6
|
numberOfChannels: options.numberOfChannels,
|
|
@@ -8,17 +8,22 @@ export function createRecordingOptions(options) {
|
|
|
8
8
|
isMeteringEnabled: options.isMeteringEnabled ?? false,
|
|
9
9
|
};
|
|
10
10
|
if (Platform.OS === 'ios') {
|
|
11
|
-
|
|
11
|
+
return {
|
|
12
12
|
...commonOptions,
|
|
13
13
|
...options.ios,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
else if (Platform.OS === 'android') {
|
|
17
|
-
|
|
17
|
+
return {
|
|
18
18
|
...commonOptions,
|
|
19
19
|
...options.android,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
else {
|
|
23
|
+
return {
|
|
24
|
+
...commonOptions,
|
|
25
|
+
...options.web,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiB7C,MAAM,UAAU,sBAAsB,CACpC,OAAyB;IAEzB,MAAM,aAAa,GAA2B;QAC5C,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,KAAK;KACtD,CAAC;IAEF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO;YACL,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,GAAG;SACf,CAAC;IACJ,CAAC;SAAM,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO;YACL,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,OAAO;SACnB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO;YACL,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,GAAG;SACf,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport {\n RecordingOptions,\n RecordingOptionsAndroid,\n RecordingOptionsIos,\n RecordingOptionsWeb,\n} from '../Audio.types';\n\ntype CommonRecordingOptions = {\n extension: string;\n sampleRate: number;\n numberOfChannels: number;\n bitRate: number;\n isMeteringEnabled: boolean;\n};\n\nexport function createRecordingOptions(\n options: RecordingOptions\n): CommonRecordingOptions & (RecordingOptionsIos | RecordingOptionsAndroid | RecordingOptionsWeb) {\n const commonOptions: CommonRecordingOptions = {\n extension: options.extension,\n sampleRate: options.sampleRate,\n numberOfChannels: options.numberOfChannels,\n bitRate: options.bitRate,\n isMeteringEnabled: options.isMeteringEnabled ?? false,\n };\n\n if (Platform.OS === 'ios') {\n return {\n ...commonOptions,\n ...options.ios,\n };\n } else if (Platform.OS === 'android') {\n return {\n ...commonOptions,\n ...options.android,\n };\n } else {\n return {\n ...commonOptions,\n ...options.web,\n };\n }\n}\n"]}
|
package/expo-module.config.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1a01e47a9aa392eec5f7c31480580bde
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ff18dfc39d4d6f05213470c7d27acb7bec39a00a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
284bbf22a464b78f1dcce8f7198fefdb601496e188a7973a1b3abbc3aac8c2c8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f7fa7c7c477f388a665bd0b61323b37b9cb9e935bbcce6ebd822d964d01ee29203c9386d5f0c6076c18a3f87a6dcfc26ab1c9f57f66760558b95cdbab959eb3b
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
39905f248120cffb241b5736663dd7de
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24e968c6b72a7c14294210c44a55ea84cfd1ff0a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
025a97ea09cade6fd74f503615195cb8232a6b0599e388c92db47b24a7c98486
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e28f5af476ae1d5639c75a8d7eb9e09befe3ea00e2587f1973c7905baa8f5047ce56df6098bcf930e4feaacbb8f3fbeb6e8b634cb62b512c2dad5710516e640a
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "expo.modules.audio",
|
|
5
5
|
"module": "expo.modules.audio",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.15",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.audio-1.0.
|
|
28
|
-
"url": "expo.modules.audio-1.0.
|
|
29
|
-
"size":
|
|
30
|
-
"sha512": "
|
|
31
|
-
"sha256": "
|
|
32
|
-
"sha1": "
|
|
33
|
-
"md5": "
|
|
27
|
+
"name": "expo.modules.audio-1.0.15.aar",
|
|
28
|
+
"url": "expo.modules.audio-1.0.15.aar",
|
|
29
|
+
"size": 214174,
|
|
30
|
+
"sha512": "e28f5af476ae1d5639c75a8d7eb9e09befe3ea00e2587f1973c7905baa8f5047ce56df6098bcf930e4feaacbb8f3fbeb6e8b634cb62b512c2dad5710516e640a",
|
|
31
|
+
"sha256": "025a97ea09cade6fd74f503615195cb8232a6b0599e388c92db47b24a7c98486",
|
|
32
|
+
"sha1": "24e968c6b72a7c14294210c44a55ea84cfd1ff0a",
|
|
33
|
+
"md5": "39905f248120cffb241b5736663dd7de"
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
},
|
|
@@ -95,13 +95,13 @@
|
|
|
95
95
|
],
|
|
96
96
|
"files": [
|
|
97
97
|
{
|
|
98
|
-
"name": "expo.modules.audio-1.0.
|
|
99
|
-
"url": "expo.modules.audio-1.0.
|
|
100
|
-
"size":
|
|
101
|
-
"sha512": "
|
|
102
|
-
"sha256": "
|
|
103
|
-
"sha1": "
|
|
104
|
-
"md5": "
|
|
98
|
+
"name": "expo.modules.audio-1.0.15.aar",
|
|
99
|
+
"url": "expo.modules.audio-1.0.15.aar",
|
|
100
|
+
"size": 214174,
|
|
101
|
+
"sha512": "e28f5af476ae1d5639c75a8d7eb9e09befe3ea00e2587f1973c7905baa8f5047ce56df6098bcf930e4feaacbb8f3fbeb6e8b634cb62b512c2dad5710516e640a",
|
|
102
|
+
"sha256": "025a97ea09cade6fd74f503615195cb8232a6b0599e388c92db47b24a7c98486",
|
|
103
|
+
"sha1": "24e968c6b72a7c14294210c44a55ea84cfd1ff0a",
|
|
104
|
+
"md5": "39905f248120cffb241b5736663dd7de"
|
|
105
105
|
}
|
|
106
106
|
]
|
|
107
107
|
},
|
|
@@ -115,13 +115,13 @@
|
|
|
115
115
|
},
|
|
116
116
|
"files": [
|
|
117
117
|
{
|
|
118
|
-
"name": "expo.modules.audio-1.0.
|
|
119
|
-
"url": "expo.modules.audio-1.0.
|
|
120
|
-
"size":
|
|
121
|
-
"sha512": "
|
|
122
|
-
"sha256": "
|
|
123
|
-
"sha1": "
|
|
124
|
-
"md5": "
|
|
118
|
+
"name": "expo.modules.audio-1.0.15-sources.jar",
|
|
119
|
+
"url": "expo.modules.audio-1.0.15-sources.jar",
|
|
120
|
+
"size": 13480,
|
|
121
|
+
"sha512": "f7fa7c7c477f388a665bd0b61323b37b9cb9e935bbcce6ebd822d964d01ee29203c9386d5f0c6076c18a3f87a6dcfc26ab1c9f57f66760558b95cdbab959eb3b",
|
|
122
|
+
"sha256": "284bbf22a464b78f1dcce8f7198fefdb601496e188a7973a1b3abbc3aac8c2c8",
|
|
123
|
+
"sha1": "ff18dfc39d4d6f05213470c7d27acb7bec39a00a",
|
|
124
|
+
"md5": "1a01e47a9aa392eec5f7c31480580bde"
|
|
125
125
|
}
|
|
126
126
|
]
|
|
127
127
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5854a6f09165a517109940b93a26e222
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ae183f5b7ceec790b3c9104404da72bd0e29b37c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
708ef0a100f8e9ffd438d83a2a5db4f6a26fe0a7595f96b7bfc351f55a0645e5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cb4e00189e5ed21b1963ef4a4eb591481b4f068ae25882377770807fe995b6c672cc41cffb07fdd98bdb7e93a2ecb8fbec91867dcdbae1f98080d69e73fc6272
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>expo.modules.audio</groupId>
|
|
11
11
|
<artifactId>expo.modules.audio</artifactId>
|
|
12
|
-
<version>1.0.
|
|
12
|
+
<version>1.0.15</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.audio</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
9351529f967df40a7791f7b13f74c578
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
63447eac4eb010676084872b4af50f0418e2f696
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
eebd34ec5379bc92275c3cdeb4edb1b06d5ee5cd627060d3f3e142a26a6fbf1d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
44f7d5c145b3c86ecd2695e935fc193f1841458b71048edde7387c1e8c78a8310a9b6a536eb93a22386da8f9b0fa4116f130de9bb7a9fbc67cba897a396056f4
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>expo.modules.audio</groupId>
|
|
4
4
|
<artifactId>expo.modules.audio</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>1.0.
|
|
7
|
-
<release>1.0.
|
|
6
|
+
<latest>1.0.15</latest>
|
|
7
|
+
<release>1.0.15</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>1.0.
|
|
9
|
+
<version>1.0.15</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20251121144917</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ceb431962cc32411fa0668bbe2faae07
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
62787b6fbbb0e0059909a0212be119bbd084cbd3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4534e7370a910afe808d8e8873e0d68650e6236f1147de05be0862259bbabf73
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
97f4d6ea51f2107912f0107666695f4c17594b8d464a93182d0ff25175f5275fa8c89d1bc928e4a78e1367f057f39deb6b350946b6a80577a4e2af869e3f7d9a
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-audio",
|
|
3
3
|
"title": "Expo Audio",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.15",
|
|
5
5
|
"description": "A cross-platform audio library for React Native and Expo apps.",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"react-native": "*",
|
|
42
42
|
"expo-asset": "*"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "7c8feba9d251fd369968dcdeb3eb388929166387"
|
|
45
45
|
}
|
package/src/Audio.types.ts
CHANGED
package/src/AudioModule.web.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
RecorderState,
|
|
11
11
|
RecordingInput,
|
|
12
12
|
RecordingOptions,
|
|
13
|
+
RecordingOptionsWeb,
|
|
13
14
|
RecordingStartOptions,
|
|
14
15
|
} from './Audio.types';
|
|
15
16
|
import { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './AudioEventKeys';
|
|
@@ -452,7 +453,9 @@ export class AudioRecorderWeb
|
|
|
452
453
|
this.timeoutIds.forEach((id) => clearTimeout(id));
|
|
453
454
|
}
|
|
454
455
|
|
|
455
|
-
private async createMediaRecorder(
|
|
456
|
+
private async createMediaRecorder(
|
|
457
|
+
options: Partial<RecordingOptions> & Partial<RecordingOptionsWeb>
|
|
458
|
+
): Promise<MediaRecorder> {
|
|
456
459
|
if (typeof navigator !== 'undefined' && !navigator.mediaDevices) {
|
|
457
460
|
throw new Error('No media devices available');
|
|
458
461
|
}
|
|
@@ -462,10 +465,23 @@ export class AudioRecorderWeb
|
|
|
462
465
|
|
|
463
466
|
const stream = await getUserMedia({ audio: true });
|
|
464
467
|
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
468
|
+
const defaults = RecordingPresets.HIGH_QUALITY.web;
|
|
469
|
+
const mediaRecorderOptions: MediaRecorderOptions = {};
|
|
470
|
+
|
|
471
|
+
const mimeType = options.mimeType ?? defaults.mimeType;
|
|
472
|
+
if (mimeType && MediaRecorder.isTypeSupported(mimeType)) {
|
|
473
|
+
mediaRecorderOptions.mimeType = mimeType;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (options.bitsPerSecond) {
|
|
477
|
+
mediaRecorderOptions.bitsPerSecond = options.bitsPerSecond;
|
|
478
|
+
} else if (options.bitRate) {
|
|
479
|
+
mediaRecorderOptions.audioBitsPerSecond = options.bitRate;
|
|
480
|
+
} else {
|
|
481
|
+
mediaRecorderOptions.bitsPerSecond = defaults.bitsPerSecond;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const mediaRecorder = new MediaRecorder(stream, mediaRecorderOptions);
|
|
469
485
|
|
|
470
486
|
mediaRecorder.addEventListener('pause', () => {
|
|
471
487
|
this.currentTime = this.getAudioRecorderDurationMillis();
|
package/src/ExpoAudio.web.ts
CHANGED
|
@@ -183,11 +183,31 @@ export function useAudioRecorderState(recorder: AudioRecorder, interval: number
|
|
|
183
183
|
const [state, setState] = useState<RecorderState>(recorder.getStatus());
|
|
184
184
|
|
|
185
185
|
useEffect(() => {
|
|
186
|
-
const
|
|
187
|
-
|
|
186
|
+
const int = setInterval(() => {
|
|
187
|
+
const newState = recorder.getStatus();
|
|
188
|
+
|
|
189
|
+
setState((prevState) => {
|
|
190
|
+
const meteringChanged =
|
|
191
|
+
(prevState.metering === undefined) !== (newState.metering === undefined) ||
|
|
192
|
+
(prevState.metering !== undefined &&
|
|
193
|
+
newState.metering !== undefined &&
|
|
194
|
+
Math.abs(prevState.metering - newState.metering) > 0.1);
|
|
195
|
+
|
|
196
|
+
if (
|
|
197
|
+
prevState.canRecord !== newState.canRecord ||
|
|
198
|
+
prevState.isRecording !== newState.isRecording ||
|
|
199
|
+
prevState.mediaServicesDidReset !== newState.mediaServicesDidReset ||
|
|
200
|
+
prevState.url !== newState.url ||
|
|
201
|
+
Math.abs(prevState.durationMillis - newState.durationMillis) > 50 ||
|
|
202
|
+
meteringChanged
|
|
203
|
+
) {
|
|
204
|
+
return newState;
|
|
205
|
+
}
|
|
206
|
+
return prevState;
|
|
207
|
+
});
|
|
188
208
|
}, interval);
|
|
189
209
|
|
|
190
|
-
return () => clearInterval(
|
|
210
|
+
return () => clearInterval(int);
|
|
191
211
|
}, [recorder.id]);
|
|
192
212
|
|
|
193
213
|
return state;
|
package/src/utils/options.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { Platform } from 'expo-modules-core';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
RecordingOptions,
|
|
5
|
+
RecordingOptionsAndroid,
|
|
6
|
+
RecordingOptionsIos,
|
|
7
|
+
RecordingOptionsWeb,
|
|
8
|
+
} from '../Audio.types';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
type CommonRecordingOptions = {
|
|
11
|
+
extension: string;
|
|
12
|
+
sampleRate: number;
|
|
13
|
+
numberOfChannels: number;
|
|
14
|
+
bitRate: number;
|
|
15
|
+
isMeteringEnabled: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function createRecordingOptions(
|
|
19
|
+
options: RecordingOptions
|
|
20
|
+
): CommonRecordingOptions & (RecordingOptionsIos | RecordingOptionsAndroid | RecordingOptionsWeb) {
|
|
21
|
+
const commonOptions: CommonRecordingOptions = {
|
|
7
22
|
extension: options.extension,
|
|
8
23
|
sampleRate: options.sampleRate,
|
|
9
24
|
numberOfChannels: options.numberOfChannels,
|
|
@@ -12,15 +27,19 @@ export function createRecordingOptions(options: RecordingOptions) {
|
|
|
12
27
|
};
|
|
13
28
|
|
|
14
29
|
if (Platform.OS === 'ios') {
|
|
15
|
-
|
|
30
|
+
return {
|
|
16
31
|
...commonOptions,
|
|
17
32
|
...options.ios,
|
|
18
33
|
};
|
|
19
34
|
} else if (Platform.OS === 'android') {
|
|
20
|
-
|
|
35
|
+
return {
|
|
21
36
|
...commonOptions,
|
|
22
37
|
...options.android,
|
|
23
38
|
};
|
|
39
|
+
} else {
|
|
40
|
+
return {
|
|
41
|
+
...commonOptions,
|
|
42
|
+
...options.web,
|
|
43
|
+
};
|
|
24
44
|
}
|
|
25
|
-
return commonOptions;
|
|
26
45
|
}
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
75f5635428f27c96f7f4bfb91bb72983
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5cf81045faab61ba9cd5cbca3fd7882e4381f698
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
879bcc38fafac9a432d203e7e20b77b86e715ae98135a136d697088eecfad342
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
812bca133e8ce5fbd8b633f0e72ca052e36f10c04571752b40ac9eb9479a65b5f77c871cdaad8b90c46063e0cd94e570a79e74271d0d894b917cbcdd42dbcd88
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cb7259b16d48d8c8379b40bbbc190d7d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1eea54d1cc3a6f9c48e49f21648f247fab40d4c5
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0b0e3890014fa236c84fb7dfd95efc3ce516c8b514fd4796fd205cf40107b6f5
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
8462afbb7216248cf9732daad17ae841dc4f56a6ea9e88cffbdaf7e95ba6655cbb4045c7a7f9aefad87692556da10a7da8c1ca8e2c18afbc12c42df39e874bba
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b01856d96b635dc7598bed6b1d171169
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
6fbbb842f46c10a8c32eaef2afcea134a69bcc3f
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
161d0215a879739de4a339a6fca8750eaf80befb87ed0a52c5ae26f8cfc6fdab
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d196ea137c4fae87da87ae09e104a3dde9c09e1f6422889e9aaae9dc3b8e74f2de03ee7256f6e4115227464de0d5c1762a53d49a3209769f16bc9039554b1ced
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2e900c1a34fafea033473301d0ba5de1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
55ce7285d19ef7aadd2d4ed2ad6ee9db8b210ea3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fee9787c1f09419f87da66ef161a05b5d458ac0806cfc36192ae20479ea24e25
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
13695379d913f0f1a3341763e3a22917edfe67778da02a0d0246bf993279b2c45696eb35c18a8e0de89735745bc9a0a326939741124e209c336fa2600fdcdaaf
|