expo-audio 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/audio/AudioModule.kt +33 -20
  4. package/android/src/main/java/expo/modules/audio/AudioPlayer.kt +20 -4
  5. package/android/src/main/java/expo/modules/audio/AudioRecorder.kt +4 -3
  6. package/android/src/main/java/expo/modules/audio/AudioRecords.kt +2 -1
  7. package/build/Audio.types.d.ts +11 -2
  8. package/build/Audio.types.d.ts.map +1 -1
  9. package/build/Audio.types.js.map +1 -1
  10. package/build/AudioModule.types.d.ts +3 -3
  11. package/build/AudioModule.types.d.ts.map +1 -1
  12. package/build/AudioModule.types.js +1 -1
  13. package/build/AudioModule.types.js.map +1 -1
  14. package/build/AudioModule.web.d.ts.map +1 -1
  15. package/build/AudioModule.web.js +14 -1
  16. package/build/AudioModule.web.js.map +1 -1
  17. package/build/ExpoAudio.d.ts +1 -1
  18. package/build/ExpoAudio.d.ts.map +1 -1
  19. package/build/ExpoAudio.js +7 -1
  20. package/build/ExpoAudio.js.map +1 -1
  21. package/build/utils/options.d.ts +1 -0
  22. package/build/utils/options.d.ts.map +1 -1
  23. package/build/utils/options.js +1 -0
  24. package/build/utils/options.js.map +1 -1
  25. package/build/utils/resolveAssetSource.web.d.ts +4 -0
  26. package/build/utils/resolveAssetSource.web.d.ts.map +1 -0
  27. package/build/utils/resolveAssetSource.web.js +14 -0
  28. package/build/utils/resolveAssetSource.web.js.map +1 -0
  29. package/build/utils/resolveSource.d.ts.map +1 -1
  30. package/build/utils/resolveSource.js.map +1 -1
  31. package/ios/AudioModule.swift +4 -4
  32. package/ios/AudioPlayer.swift +38 -10
  33. package/ios/AudioRecorder.swift +3 -0
  34. package/ios/AudioRecords.swift +1 -0
  35. package/ios/AudioTapProcessor.h +2 -2
  36. package/ios/AudioTapProcessor.m +10 -10
  37. package/package.json +2 -2
  38. package/src/Audio.types.ts +12 -2
  39. package/src/AudioModule.types.ts +3 -3
  40. package/src/AudioModule.web.ts +16 -1
  41. package/src/ExpoAudio.ts +9 -2
  42. package/src/utils/options.ts +1 -0
  43. package/src/utils/resolveAssetSource.web.ts +15 -0
  44. package/src/utils/resolveSource.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,22 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.3.2 — 2025-01-08
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Expose `isMeteringEnabled` to `JS`. ([#33713](https://github.com/expo/expo/pull/33713) by [@alanjhughes](https://github.com/alanjhughes))
18
+ - On `Android`, allow player to accept a `null` audio source. ([#33854](https://github.com/expo/expo/pull/33854) by [@alanjhughes](https://github.com/alanjhughes))
19
+ - Override the `replace` method on the `AudioPlayer` so the source can be parsed correctly. ([#33708](https://github.com/expo/expo/pull/33708) by [@alanjhughes](https://github.com/alanjhughes))
20
+
21
+ ## 0.3.1 — 2024-12-16
22
+
23
+ ### 🐛 Bug fixes
24
+
25
+ - Update docs and API so all units of time are returned as seconds, not milliseconds. ([#33320](https://github.com/expo/expo/pull/33320) by [@alanjhughes](https://github.com/alanjhughes))
26
+ - Fix `AudioSource` to accept numbers for loading local assets. ([#33676](https://github.com/expo/expo/pull/33676) by [@alanjhughes](https://github.com/alanjhughes))
27
+ - Expose `isMeteringEnabled` to `JS`. ([#33713](https://github.com/expo/expo/pull/33713) by [@alanjhughes](https://github.com/alanjhughes))
28
+
13
29
  ## 0.3.0 — 2024-12-02
14
30
 
15
31
  ### 🎉 New features
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'expo.modules.audio'
4
- version = '0.3.0'
4
+ version = '0.3.2'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.audio"
15
15
  defaultConfig {
16
16
  versionCode 1
17
- versionName "0.3.0"
17
+ versionName "0.3.2"
18
18
  }
19
19
 
20
20
  compileOptions {
@@ -218,13 +218,13 @@ class AudioModule : Module() {
218
218
 
219
219
  Property("currentTime") { ref ->
220
220
  runOnMain {
221
- ref.player.currentPosition
221
+ ref.currentTime
222
222
  }
223
223
  }
224
224
 
225
225
  Property("duration") { ref ->
226
226
  runOnMain {
227
- ref.player.duration
227
+ ref.duration
228
228
  }
229
229
  }
230
230
 
@@ -239,7 +239,7 @@ class AudioModule : Module() {
239
239
  ref.player.volume
240
240
  }
241
241
  }.set { ref, volume: Float ->
242
- appContext.mainQueue.launch {
242
+ runOnMain {
243
243
  ref.player.volume = volume
244
244
  }
245
245
  }
@@ -249,32 +249,40 @@ class AudioModule : Module() {
249
249
  Log.e(TAG, "Audio has been disabled. Re-enable to start playing")
250
250
  return@Function
251
251
  }
252
- appContext.mainQueue.launch {
252
+ runOnMain {
253
253
  ref.player.play()
254
254
  }
255
255
  }
256
256
 
257
257
  Function("pause") { ref: AudioPlayer ->
258
- appContext.mainQueue.launch {
258
+ runOnMain {
259
259
  ref.player.pause()
260
260
  }
261
261
  }
262
262
 
263
263
  Function("replace") { ref: AudioPlayer, source: AudioSource ->
264
- if (ref.player.availableCommands.contains(Player.COMMAND_CHANGE_MEDIA_ITEMS)) {
265
- val mediaSource = createMediaItem(source)
266
- ref.player.replaceMediaItem(0, mediaSource.mediaItem)
264
+ runOnMain {
265
+ if (ref.player.availableCommands.contains(Player.COMMAND_CHANGE_MEDIA_ITEMS)) {
266
+ val mediaSource = createMediaItem(source)
267
+ val wasPlaying = ref.player.isPlaying
268
+ mediaSource?.let {
269
+ ref.player.replaceMediaItem(0, it.mediaItem)
270
+ if (wasPlaying) {
271
+ ref.player.play()
272
+ }
273
+ }
274
+ }
267
275
  }
268
276
  }
269
277
 
270
278
  Function("setAudioSamplingEnabled") { ref: AudioPlayer, enabled: Boolean ->
271
- appContext.mainQueue.launch {
279
+ runOnMain {
272
280
  ref.setSamplingEnabled(enabled)
273
281
  }
274
282
  }
275
283
 
276
284
  AsyncFunction("seekTo") { ref: AudioPlayer, seekTime: Double ->
277
- ref.player.seekTo(seekTime.toLong())
285
+ ref.player.seekTo((seekTime * 1000L).toLong())
278
286
  }.runOnQueue(Queues.MAIN)
279
287
 
280
288
  Function("setPlaybackRate") { ref: AudioPlayer, rate: Float ->
@@ -355,25 +363,30 @@ class AudioModule : Module() {
355
363
  }
356
364
  }
357
365
 
358
- private fun createMediaItem(source: AudioSource?): MediaSource {
359
- val isLocal = Util.isLocalFileUri(Uri.parse(source?.uri))
360
- val factory = if (isLocal) {
366
+ private fun createMediaItem(source: AudioSource?): MediaSource? = source?.let {
367
+ val factory = createDataSourceFactory(it)
368
+ it.uri?.let { uri ->
369
+ val item = MediaItem.fromUri(uri)
370
+ buildMediaSourceFactory(factory, item)
371
+ }
372
+ }
373
+
374
+ private fun createDataSourceFactory(audioSource: AudioSource): DataSource.Factory {
375
+ val isLocal = Util.isLocalFileUri(Uri.parse(audioSource.uri))
376
+ return if (isLocal) {
361
377
  DefaultDataSource.Factory(context)
362
378
  } else {
363
379
  OkHttpDataSource.Factory(httpClient).apply {
364
- source?.headers?.let {
365
- setDefaultRequestProperties(it)
380
+ audioSource.headers?.let { headers ->
381
+ setDefaultRequestProperties(headers)
366
382
  }
367
383
  DefaultDataSource.Factory(context, this)
368
384
  }
369
385
  }
370
-
371
- val item = MediaItem.fromUri(source?.uri ?: "")
372
- return buildMediaSourceFactory(factory, item)
373
386
  }
374
387
 
375
388
  private fun updatePlaySoundThroughEarpiece(playThroughEarpiece: Boolean) {
376
- audioManager.setMode(if (playThroughEarpiece) AudioManager.MODE_IN_COMMUNICATION else AudioManager.MODE_NORMAL)
389
+ audioManager.mode = if (playThroughEarpiece) AudioManager.MODE_IN_COMMUNICATION else AudioManager.MODE_NORMAL
377
390
  audioManager.setSpeakerphoneOn(!playThroughEarpiece)
378
391
  }
379
392
 
@@ -384,7 +397,7 @@ class AudioModule : Module() {
384
397
  mediaItem: MediaItem
385
398
  ): MediaSource {
386
399
  val uri = mediaItem.localConfiguration?.uri
387
- val newFactory = when (val type = retrieveStreamType(uri!!)) {
400
+ val newFactory = when (val type = uri?.let { retrieveStreamType(it) }) {
388
401
  CONTENT_TYPE_SS -> SsMediaSource.Factory(factory)
389
402
  CONTENT_TYPE_DASH -> DashMediaSource.Factory(factory)
390
403
  CONTENT_TYPE_HLS -> HlsMediaSource.Factory(factory)
@@ -7,7 +7,10 @@ import android.media.audiofx.Visualizer
7
7
  import android.util.Log
8
8
  import androidx.core.content.ContextCompat
9
9
  import androidx.media3.common.AudioAttributes
10
+ import androidx.media3.common.C
11
+ import androidx.media3.common.MediaItem
10
12
  import androidx.media3.common.Player
13
+ import androidx.media3.common.Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED
11
14
  import androidx.media3.common.util.UnstableApi
12
15
  import androidx.media3.exoplayer.ExoPlayer
13
16
  import androidx.media3.exoplayer.source.MediaSource
@@ -29,14 +32,16 @@ private const val AUDIO_SAMPLE_UPDATE = "audioSampleUpdate"
29
32
  class AudioPlayer(
30
33
  context: Context,
31
34
  appContext: AppContext,
32
- source: MediaSource,
35
+ source: MediaSource?,
33
36
  updateInterval: Double
34
37
  ) : SharedRef<ExoPlayer>(
35
38
  ExoPlayer.Builder(context)
36
39
  .setLooper(context.mainLooper)
37
40
  .build()
38
41
  .apply {
39
- setMediaSource(source)
42
+ source?.let {
43
+ setMediaSource(it)
44
+ }
40
45
  setAudioAttributes(AudioAttributes.DEFAULT, true)
41
46
  prepare()
42
47
  },
@@ -51,6 +56,9 @@ class AudioPlayer(
51
56
  private var samplingEnabled = false
52
57
  private var visualizer: Visualizer? = null
53
58
 
59
+ val currentTime get() = player.currentPosition / 1000
60
+ val duration get() = if (player.duration != C.TIME_UNSET) player.duration / 1000 else 0
61
+
54
62
  init {
55
63
  addPlayerListeners()
56
64
  player.setAudioAttributes(AudioAttributes.DEFAULT, true)
@@ -81,6 +89,14 @@ class AudioPlayer(
81
89
  sendPlayerUpdate(mapOf("status" to playbackStateToString(playbackState)))
82
90
  }
83
91
  }
92
+
93
+ override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
94
+ if (reason == MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED) {
95
+ playerScope.launch {
96
+ sendPlayerUpdate()
97
+ }
98
+ }
99
+ }
84
100
  })
85
101
  }
86
102
 
@@ -107,12 +123,12 @@ class AudioPlayer(
107
123
 
108
124
  return mapOf(
109
125
  "id" to id,
110
- "currentTime" to player.currentPosition,
126
+ "currentTime" to currentTime,
111
127
  "playbackState" to playbackStateToString(player.playbackState),
112
128
  "timeControlStatus" to if (player.isPlaying) "playing" else "paused",
113
129
  "reasonForWaitingToPlay" to null,
114
130
  "mute" to isMuted,
115
- "duration" to player.duration,
131
+ "duration" to duration,
116
132
  "playing" to player.isPlaying,
117
133
  "loop" to isLooping,
118
134
  "isLoaded" to if (player.playbackState == Player.STATE_ENDED) true else isLoaded,
@@ -28,7 +28,7 @@ class AudioRecorder(
28
28
  MediaRecorder.OnErrorListener,
29
29
  MediaRecorder.OnInfoListener {
30
30
  private var filePath: String? = null
31
- private var meteringEnabled = false
31
+ private var meteringEnabled = options.isMeteringEnabled
32
32
  private var durationAlreadyRecorded = 0L
33
33
  private var isPrepared = false
34
34
  private var shouldCreateRecorder = false
@@ -148,7 +148,8 @@ class AudioRecorder(
148
148
  }
149
149
  }
150
150
 
151
- override fun deallocate() {
151
+ override fun sharedObjectDidRelease() {
152
+ super.sharedObjectDidRelease()
152
153
  recorder.release()
153
154
  }
154
155
 
@@ -215,7 +216,7 @@ class AudioRecorder(
215
216
  // getRoutedDevice() is the most reliable way to return the actual mic input, however it
216
217
  // only returns a valid device when actively recording, and may throw otherwise.
217
218
  // https://developer.android.com/reference/android/media/MediaRecorder#getRoutedDevice()
218
- deviceInfo = recorder.getRoutedDevice()
219
+ deviceInfo = recorder.routedDevice
219
220
  } catch (e: java.lang.Exception) {
220
221
  // no-op
221
222
  }
@@ -32,7 +32,8 @@ data class RecordingOptions(
32
32
  @Field val bitRate: Double?,
33
33
  @Field val outputFormat: AndroidOutputFormat?,
34
34
  @Field val audioEncoder: AndroidAudioEncoder?,
35
- @Field val maxFileSize: Int?
35
+ @Field val maxFileSize: Int?,
36
+ @Field val isMeteringEnabled: Boolean = false
36
37
  ) : Record
37
38
 
38
39
  enum class AndroidOutputFormat(val value: String) : Enumerable {
@@ -1,15 +1,20 @@
1
- export type AudioSource = string | {
1
+ export type AudioSource = string | number | null | {
2
2
  /**
3
3
  * A string representing the resource identifier for the audio,
4
4
  * which could be an HTTPS address, a local file path, or the name of a static audio file resource.
5
5
  */
6
6
  uri?: string;
7
+ /**
8
+ * The asset ID of a local audio asset, acquired with the `require` function.
9
+ * This property is exclusive with the `uri` property. When both are present, the `assetId` will be ignored.
10
+ */
11
+ assetId?: number;
7
12
  /**
8
13
  * An object representing the HTTP headers to send along with the request for a remote audio source.
9
14
  * On web requires the `Access-Control-Allow-Origin` header returned by the server to include the current domain.
10
15
  */
11
16
  headers?: Record<string, string>;
12
- } | null;
17
+ };
13
18
  export type RecordingInput = {
14
19
  name: string;
15
20
  type: string;
@@ -93,6 +98,10 @@ export declare enum AudioQuality {
93
98
  }
94
99
  export type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';
95
100
  export type RecordingOptions = {
101
+ /**
102
+ * A boolean that determines whether audio level information will be part of the status object under the "metering" key.
103
+ */
104
+ isMeteringEnabled?: boolean;
96
105
  /**
97
106
  * The desired file extension.
98
107
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Audio.types.d.ts","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACnB,MAAM,GACN;IACE;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAC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ACzB,+BAAY,CAAA;IACZ,kCAAe,CAAA;IACf,mCAAgB,CAAA;IAChB,gCAAa,CAAA;IACb,4EAAwB,CAAA;IACxB,8EAAyB,CAAA;IACzB,gCAAa,CAAA;IACb,uCAAoB,CAAA;AACtB,CAAC,EAnCW,eAAe,KAAf,eAAe,QAmC1B;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,6CAAO,CAAA;IACP,8CAAU,CAAA;IACV,oDAAa,CAAA;IACb,gDAAW,CAAA;IACX,+CAAU,CAAA;AACZ,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB","sourcesContent":["export type AudioSource =\n | string\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 * 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 | null;\n\nexport type RecordingInput = {\n name: string;\n type: string;\n uid: string;\n};\n\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\nexport type AudioStatus = {\n id: number;\n currentTime: number;\n playbackState: string;\n timeControlStatus: string;\n reasonForWaitingToPlay: string;\n mute: boolean;\n duration: number;\n playing: boolean;\n loop: boolean;\n isBuffering: boolean;\n isLoaded: boolean;\n playbackRate: number;\n shouldCorrectPitch: boolean;\n};\n\nexport type RecordingStatus = {\n id: number;\n isFinished: boolean;\n hasError: boolean;\n error: string | null;\n url: string | null;\n};\n\nexport type RecorderState = {\n canRecord: boolean;\n isRecording: boolean;\n durationMillis: number;\n mediaServicesDidReset: boolean;\n metering?: number;\n url: string | null;\n};\n\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\nexport enum IOSOutputFormat {\n LINEARPCM = 'lpcm',\n AC3 = 'ac-3',\n '60958AC3' = 'cac3',\n APPLEIMA4 = 'ima4',\n MPEG4AAC = 'aac ',\n MPEG4CELP = 'celp',\n MPEG4HVXC = 'hvxc',\n MPEG4TWINVQ = 'twvq',\n MACE3 = 'MAC3',\n MACE6 = 'MAC6',\n ULAW = 'ulaw',\n ALAW = 'alaw',\n QDESIGN = 'QDMC',\n QDESIGN2 = 'QDM2',\n QUALCOMM = 'Qclp',\n MPEGLAYER1 = '.mp1',\n MPEGLAYER2 = '.mp2',\n MPEGLAYER3 = '.mp3',\n APPLELOSSLESS = 'alac',\n MPEG4AAC_HE = 'aach',\n MPEG4AAC_LD = 'aacl',\n MPEG4AAC_ELD = 'aace',\n MPEG4AAC_ELD_SBR = 'aacf',\n MPEG4AAC_ELD_V2 = 'aacg',\n MPEG4AAC_HE_V2 = 'aacp',\n MPEG4AAC_SPATIAL = 'aacs',\n AMR = 'samr',\n AMR_WB = 'sawb',\n AUDIBLE = 'AUDB',\n ILBC = 'ilbc',\n DVIINTELIMA = 0x6d730011,\n MICROSOFTGSM = 0x6d730031,\n AES3 = 'aes3',\n ENHANCEDAC3 = 'ec-3',\n}\n\nexport enum AudioQuality {\n MIN = 0,\n LOW = 0x20,\n MEDIUM = 0x40,\n HIGH = 0x60,\n MAX = 0x7f,\n}\n\nexport type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';\n\nexport type RecordingOptions = {\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 */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n */\n web?: RecordingOptionsWeb;\n};\n\nexport type RecordingOptionsWeb = {\n mimeType?: string;\n bitsPerSecond?: number;\n};\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\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\nexport type AudioMode = {\n playsInSilentMode: boolean;\n interruptionMode: InterruptionMode;\n allowsRecording: boolean;\n shouldPlayInBackground: boolean;\n shouldRouteThroughEarpiece: boolean;\n};\n\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n"]}
1
+ {"version":3,"file":"Audio.types.js","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"AA2EA,MAAM,CAAN,IAAY,eAmCX;AAnCD,WAAY,eAAe;IACzB,qCAAkB,CAAA;IAClB,+BAAY,CAAA;IACZ,oCAAmB,CAAA;IACnB,qCAAkB,CAAA;IAClB,oCAAiB,CAAA;IACjB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,uCAAoB,CAAA;IACpB,iCAAc,CAAA;IACd,iCAAc,CAAA;IACd,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,mCAAgB,CAAA;IAChB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,yCAAsB,CAAA;IACtB,uCAAoB,CAAA;IACpB,uCAAoB,CAAA;IACpB,wCAAqB,CAAA;IACrB,4CAAyB,CAAA;IACzB,2CAAwB,CAAA;IACxB,0CAAuB,CAAA;IACvB,4CAAyB,CAAA;IACzB,+BAAY,CAAA;IACZ,kCAAe,CAAA;IACf,mCAAgB,CAAA;IAChB,gCAAa,CAAA;IACb,4EAAwB,CAAA;IACxB,8EAAyB,CAAA;IACzB,gCAAa,CAAA;IACb,uCAAoB,CAAA;AACtB,CAAC,EAnCW,eAAe,KAAf,eAAe,QAmC1B;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,6CAAO,CAAA;IACP,8CAAU,CAAA;IACV,oDAAa,CAAA;IACb,gDAAW,CAAA;IACX,+CAAU,CAAA;AACZ,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB","sourcesContent":["export 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\nexport type RecordingInput = {\n name: string;\n type: string;\n uid: string;\n};\n\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\nexport type AudioStatus = {\n id: number;\n currentTime: number;\n playbackState: string;\n timeControlStatus: string;\n reasonForWaitingToPlay: string;\n mute: boolean;\n duration: number;\n playing: boolean;\n loop: boolean;\n isBuffering: boolean;\n isLoaded: boolean;\n playbackRate: number;\n shouldCorrectPitch: boolean;\n};\n\nexport type RecordingStatus = {\n id: number;\n isFinished: boolean;\n hasError: boolean;\n error: string | null;\n url: string | null;\n};\n\nexport type RecorderState = {\n canRecord: boolean;\n isRecording: boolean;\n durationMillis: number;\n mediaServicesDidReset: boolean;\n metering?: number;\n url: string | null;\n};\n\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\nexport enum IOSOutputFormat {\n LINEARPCM = 'lpcm',\n AC3 = 'ac-3',\n '60958AC3' = 'cac3',\n APPLEIMA4 = 'ima4',\n MPEG4AAC = 'aac ',\n MPEG4CELP = 'celp',\n MPEG4HVXC = 'hvxc',\n MPEG4TWINVQ = 'twvq',\n MACE3 = 'MAC3',\n MACE6 = 'MAC6',\n ULAW = 'ulaw',\n ALAW = 'alaw',\n QDESIGN = 'QDMC',\n QDESIGN2 = 'QDM2',\n QUALCOMM = 'Qclp',\n MPEGLAYER1 = '.mp1',\n MPEGLAYER2 = '.mp2',\n MPEGLAYER3 = '.mp3',\n APPLELOSSLESS = 'alac',\n MPEG4AAC_HE = 'aach',\n MPEG4AAC_LD = 'aacl',\n MPEG4AAC_ELD = 'aace',\n MPEG4AAC_ELD_SBR = 'aacf',\n MPEG4AAC_ELD_V2 = 'aacg',\n MPEG4AAC_HE_V2 = 'aacp',\n MPEG4AAC_SPATIAL = 'aacs',\n AMR = 'samr',\n AMR_WB = 'sawb',\n AUDIBLE = 'AUDB',\n ILBC = 'ilbc',\n DVIINTELIMA = 0x6d730011,\n MICROSOFTGSM = 0x6d730031,\n AES3 = 'aes3',\n ENHANCEDAC3 = 'ec-3',\n}\n\nexport enum AudioQuality {\n MIN = 0,\n LOW = 0x20,\n MEDIUM = 0x40,\n HIGH = 0x60,\n MAX = 0x7f,\n}\n\nexport type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';\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 */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n */\n web?: RecordingOptionsWeb;\n};\n\nexport type RecordingOptionsWeb = {\n mimeType?: string;\n bitsPerSecond?: number;\n};\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\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\nexport type AudioMode = {\n playsInSilentMode: boolean;\n interruptionMode: InterruptionMode;\n allowsRecording: boolean;\n shouldPlayInBackground: boolean;\n shouldRouteThroughEarpiece: boolean;\n};\n\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n"]}
@@ -1,9 +1,9 @@
1
- import { PermissionResponse, SharedObject } from 'expo-modules-core';
1
+ import { NativeModule, PermissionResponse, SharedObject } from 'expo-modules-core';
2
2
  import { AudioMode, AudioSource, AudioStatus, PitchCorrectionQuality, RecorderState, RecordingInput, RecordingOptions, RecordingStatus } from './Audio.types';
3
3
  /**
4
4
  * @hidden
5
5
  */
6
- export declare class NativeAudioModule {
6
+ export declare class NativeAudioModule extends NativeModule {
7
7
  setIsAudioActiveAsync(active: boolean): Promise<void>;
8
8
  setAudioModeAsync(category: Partial<AudioMode>): Promise<void>;
9
9
  requestRecordingPermissionsAsync(): Promise<PermissionResponse>;
@@ -50,7 +50,7 @@ export declare class AudioPlayer extends SharedObject<AudioEvents> {
50
50
  */
51
51
  isBuffering: boolean;
52
52
  /**
53
- * The current position through the audio item, in seconds.
53
+ * The current position through the audio item in seconds.
54
54
  */
55
55
  currentTime: number;
56
56
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AudioModule.types.d.ts","sourceRoot":"","sources":["../src/AudioModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IACrD,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9D,gCAAgC,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAC/D,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAE3D,QAAQ,CAAC,WAAW,EAAE,OAAO,WAAW,CAAC;IACzC,QAAQ,CAAC,aAAa,EAAE,OAAO,aAAa,CAAC;CAC9C;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,YAAY,CAAC,WAAW,CAAC;IAChE;;;OAGG;gBACS,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM;IAEvD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAA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H,SAAS,IAAI,aAAa;IAE1B;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAE3C;;OAEG;IACH,oBAAoB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAExE;;;OAGG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CACzC;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,qBAAqB,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1D,CAAC"}
@@ -1,2 +1,2 @@
1
- import { SharedObject } from 'expo-modules-core';
1
+ import { NativeModule, SharedObject } from 'expo-modules-core';
2
2
  //# sourceMappingURL=AudioModule.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AudioModule.types.js","sourceRoot":"","sources":["../src/AudioModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["import { PermissionResponse, SharedObject } from 'expo-modules-core';\n\nimport {\n AudioMode,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\n\n/**\n * @hidden\n */\nexport declare class NativeAudioModule {\n setIsAudioActiveAsync(active: boolean): Promise<void>;\n setAudioModeAsync(category: Partial<AudioMode>): Promise<void>;\n requestRecordingPermissionsAsync(): Promise<PermissionResponse>;\n getRecordingPermissionsAsync(): Promise<PermissionResponse>;\n\n readonly AudioPlayer: typeof AudioPlayer;\n readonly AudioRecorder: typeof AudioRecorder;\n}\n\nexport declare class AudioPlayer extends SharedObject<AudioEvents> {\n /**\n * Initializes a new audio player instance with the given source.\n * @hidden\n */\n constructor(source: AudioSource, updateInterval: number);\n\n /**\n * Unique identifier for the player object.\n */\n id: number;\n\n /**\n * Boolean value indicating whether the player is currently playing.\n */\n playing: boolean;\n\n /**\n * Boolean value indicating whether the player is currently muted.\n */\n muted: boolean;\n\n /**\n * Boolean value indicating whether the player is currently looping.\n */\n loop: boolean;\n\n /**\n * Boolean value indicating whether the player is currently paused.\n */\n paused: boolean;\n\n /**\n * Boolean value indicating whether the player is finished loading.\n */\n isLoaded: boolean;\n\n /**\n * Boolean value indicating whether audio sampling is supported on the platform.\n */\n isAudioSamplingSupported: boolean;\n\n /**\n * Boolean value indicating whether the player is buffering.\n */\n isBuffering: boolean;\n\n /**\n * The current position through the audio item, in seconds.\n */\n currentTime: number;\n\n /**\n * The total duration of the audio in seconds.\n */\n duration: number;\n\n /**\n * The current volume of the audio.\n */\n volume: number;\n\n /**\n * The current playback rate of the audio.\n */\n playbackRate: number;\n\n /**\n * A boolean describing if we are correcting the pitch for a changed rate.\n */\n shouldCorrectPitch: boolean;\n\n /**\n * The current status of the audio player.\n * @hidden\n */\n currentStatus: AudioStatus;\n\n /**\n * Start playing audio.\n */\n play(): void;\n\n /**\n * Pauses the player.\n */\n pause(): void;\n\n /**\n * Replaces the current audio source with a new one.\n */\n replace(source: AudioSource): void;\n\n /**\n * Seeks the playback by the given number of seconds.\n * @param seconds The number of seconds to seek by.\n */\n seekTo(seconds: number): Promise<void>;\n\n /**\n * Sets the current playback rate of the audio.\n * @param rate The playback rate of the audio.\n * @param pitchCorrectionQuality The quality of the pitch correction.\n */\n setPlaybackRate(rate: number, pitchCorrectionQuality?: PitchCorrectionQuality): void;\n\n /**\n *\n * @hidden\n */\n setAudioSamplingEnabled(enabled: boolean): void;\n\n /**\n * Remove the player from memory to free up resources.\n */\n remove(): void;\n}\n\nexport type AudioSample = {\n channels: AudioSampleChannel[];\n timestamp: number;\n};\n\nexport type AudioSampleChannel = { frames: number[] };\n\nexport type AudioEvents = {\n playbackStatusUpdate(status: AudioStatus): void;\n audioSampleUpdate(data: AudioSample): void;\n};\n\nexport declare class AudioRecorder extends SharedObject<RecordingEvents> {\n /**\n * Initializes a new audio recorder instance with the given source.\n * @hidden\n */\n constructor(options: Partial<RecordingOptions>);\n\n /**\n * Unique identifier for the recorder object.\n */\n id: number;\n\n /**\n * The current length of the recording, in seconds.\n */\n currentTime: number;\n\n /**\n * Boolean value indicating whether the recording is in progress.\n */\n isRecording: boolean;\n\n /**\n * The uri of the recording.\n */\n uri: string | null;\n\n /**\n * Starts the recording.\n */\n record(): void;\n\n /**\n * Stop the recording.\n */\n stop(): Promise<void>;\n\n /**\n * Pause the recording.\n */\n pause(): void;\n\n /**\n * Returns a list of available recording inputs. This method can only be called if the `Recording` has been prepared.\n * @return A `Promise` that is fulfilled with an array of `RecordingInput` objects.\n */\n getAvailableInputs(): RecordingInput[];\n\n /**\n * Returns the currently-selected recording input. This method can only be called if the `Recording` has been prepared.\n * @return A `Promise` that is fulfilled with a `RecordingInput` object.\n */\n getCurrentInput(): RecordingInput;\n\n /**\n * Sets the current recording input.\n * @param inputUid The uid of a `RecordingInput`.\n * @return A `Promise` that is resolved if successful or rejected if not.\n */\n setInput(inputUid: string): void;\n\n /**\n * Status of the current recording.\n */\n getStatus(): RecorderState;\n\n /**\n * Starts the recording at the given time.\n * @param seconds The time in seconds to start recording at.\n */\n startRecordingAtTime(seconds: number): void;\n\n /**\n * Prepares the recording for recording.\n */\n prepareToRecordAsync(options?: Partial<RecordingOptions>): Promise<void>;\n\n /**\n * Stops the recording once the specified time has elapsed.\n * @param seconds The time in seconds to stop recording at.\n */\n recordForDuration(seconds: number): void;\n}\n\nexport type RecordingEvents = {\n recordingStatusUpdate: (status: RecordingStatus) => void;\n};\n"]}
1
+ {"version":3,"file":"AudioModule.types.js","sourceRoot":"","sources":["../src/AudioModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,YAAY,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["import { NativeModule, PermissionResponse, SharedObject } from 'expo-modules-core';\n\nimport {\n AudioMode,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\n\n/**\n * @hidden\n */\nexport declare class NativeAudioModule extends NativeModule {\n setIsAudioActiveAsync(active: boolean): Promise<void>;\n setAudioModeAsync(category: Partial<AudioMode>): Promise<void>;\n requestRecordingPermissionsAsync(): Promise<PermissionResponse>;\n getRecordingPermissionsAsync(): Promise<PermissionResponse>;\n\n readonly AudioPlayer: typeof AudioPlayer;\n readonly AudioRecorder: typeof AudioRecorder;\n}\n\nexport declare class AudioPlayer extends SharedObject<AudioEvents> {\n /**\n * Initializes a new audio player instance with the given source.\n * @hidden\n */\n constructor(source: AudioSource, updateInterval: number);\n\n /**\n * Unique identifier for the player object.\n */\n id: number;\n\n /**\n * Boolean value indicating whether the player is currently playing.\n */\n playing: boolean;\n\n /**\n * Boolean value indicating whether the player is currently muted.\n */\n muted: boolean;\n\n /**\n * Boolean value indicating whether the player is currently looping.\n */\n loop: boolean;\n\n /**\n * Boolean value indicating whether the player is currently paused.\n */\n paused: boolean;\n\n /**\n * Boolean value indicating whether the player is finished loading.\n */\n isLoaded: boolean;\n\n /**\n * Boolean value indicating whether audio sampling is supported on the platform.\n */\n isAudioSamplingSupported: boolean;\n\n /**\n * Boolean value indicating whether the player is buffering.\n */\n isBuffering: boolean;\n\n /**\n * The current position through the audio item in seconds.\n */\n currentTime: number;\n\n /**\n * The total duration of the audio in seconds.\n */\n duration: number;\n\n /**\n * The current volume of the audio.\n */\n volume: number;\n\n /**\n * The current playback rate of the audio.\n */\n playbackRate: number;\n\n /**\n * A boolean describing if we are correcting the pitch for a changed rate.\n */\n shouldCorrectPitch: boolean;\n\n /**\n * The current status of the audio player.\n * @hidden\n */\n currentStatus: AudioStatus;\n\n /**\n * Start playing audio.\n */\n play(): void;\n\n /**\n * Pauses the player.\n */\n pause(): void;\n\n /**\n * Replaces the current audio source with a new one.\n */\n replace(source: AudioSource): void;\n\n /**\n * Seeks the playback by the given number of seconds.\n * @param seconds The number of seconds to seek by.\n */\n seekTo(seconds: number): Promise<void>;\n\n /**\n * Sets the current playback rate of the audio.\n * @param rate The playback rate of the audio.\n * @param pitchCorrectionQuality The quality of the pitch correction.\n */\n setPlaybackRate(rate: number, pitchCorrectionQuality?: PitchCorrectionQuality): void;\n\n /**\n *\n * @hidden\n */\n setAudioSamplingEnabled(enabled: boolean): void;\n\n /**\n * Remove the player from memory to free up resources.\n */\n remove(): void;\n}\n\nexport type AudioSample = {\n channels: AudioSampleChannel[];\n timestamp: number;\n};\n\nexport type AudioSampleChannel = { frames: number[] };\n\nexport type AudioEvents = {\n playbackStatusUpdate(status: AudioStatus): void;\n audioSampleUpdate(data: AudioSample): void;\n};\n\nexport declare class AudioRecorder extends SharedObject<RecordingEvents> {\n /**\n * Initializes a new audio recorder instance with the given source.\n * @hidden\n */\n constructor(options: Partial<RecordingOptions>);\n\n /**\n * Unique identifier for the recorder object.\n */\n id: number;\n\n /**\n * The current length of the recording, in seconds.\n */\n currentTime: number;\n\n /**\n * Boolean value indicating whether the recording is in progress.\n */\n isRecording: boolean;\n\n /**\n * The uri of the recording.\n */\n uri: string | null;\n\n /**\n * Starts the recording.\n */\n record(): void;\n\n /**\n * Stop the recording.\n */\n stop(): Promise<void>;\n\n /**\n * Pause the recording.\n */\n pause(): void;\n\n /**\n * Returns a list of available recording inputs. This method can only be called if the `Recording` has been prepared.\n * @return A `Promise` that is fulfilled with an array of `RecordingInput` objects.\n */\n getAvailableInputs(): RecordingInput[];\n\n /**\n * Returns the currently-selected recording input. This method can only be called if the `Recording` has been prepared.\n * @return A `Promise` that is fulfilled with a `RecordingInput` object.\n */\n getCurrentInput(): RecordingInput;\n\n /**\n * Sets the current recording input.\n * @param inputUid The uid of a `RecordingInput`.\n * @return A `Promise` that is resolved if successful or rejected if not.\n */\n setInput(inputUid: string): void;\n\n /**\n * Status of the current recording.\n */\n getStatus(): RecorderState;\n\n /**\n * Starts the recording at the given time.\n * @param seconds The time in seconds to start recording at.\n */\n startRecordingAtTime(seconds: number): void;\n\n /**\n * Prepares the recording for recording.\n */\n prepareToRecordAsync(options?: Partial<RecordingOptions>): Promise<void>;\n\n /**\n * Stops the recording once the specified time has elapsed.\n * @param seconds The time in seconds to stop recording at.\n */\n recordForDuration(seconds: number): void;\n}\n\nexport type RecordingEvents = {\n recordingStatusUpdate: (status: RecordingStatus) => void;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AudioModule.web.d.ts","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAoF/F,qBAAa,cACX,SAAQ,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAChD,YAAW,WAAW;gBAEV,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAOjD,EAAE,EAAE,MAAM,CAAY;IACtB,wBAAwB,UAAS;IACjC,WAAW,UAAS;IACpB,kBAAkB,UAAS;IAE3B,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAS;IAEvB,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,EAEvB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,MAAM,IAAI,OAAO,C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,CAAS;IACzC,OAAO,CAAC,UAAU,CAAgB;IAElC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,MAAM,IAAI,IAAI;IAcd,kBAAkB,IAAI,cAAc,EAAE;IAItC,eAAe,IAAI,cAAc;IAQ3B,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C,SAAS,IAAI,aAAa;IAW1B,KAAK,IAAI,IAAI;IAUb,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IASxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAE7B,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B3B,aAAa;YAIC,mBAAmB;IA0CjC,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"}
@@ -1,6 +1,7 @@
1
1
  import { PermissionStatus } from 'expo-modules-core';
2
2
  import { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './ExpoAudio';
3
3
  import { RecordingPresets } from './RecordingConstants';
4
+ import resolveAssetSource from './utils/resolveAssetSource';
4
5
  const nextId = (() => {
5
6
  let id = 0;
6
7
  return () => id++;
@@ -158,7 +159,7 @@ export class AudioPlayerWeb extends globalThis.expo.SharedObject {
158
159
  getStatusFromMedia(this.media, this.id);
159
160
  }
160
161
  _createMediaElement() {
161
- const newSource = typeof this.src === 'string' ? this.src : (this.src?.uri ?? '');
162
+ const newSource = getSourceUri(this.src);
162
163
  const media = new Audio(newSource);
163
164
  media.ontimeupdate = () => {
164
165
  this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));
@@ -173,6 +174,18 @@ export class AudioPlayerWeb extends globalThis.expo.SharedObject {
173
174
  return media;
174
175
  }
175
176
  }
177
+ function getSourceUri(source) {
178
+ if (typeof source === 'string') {
179
+ return source;
180
+ }
181
+ if (typeof source === 'number') {
182
+ return resolveAssetSource(source)?.uri ?? undefined;
183
+ }
184
+ if (typeof source?.assetId === 'number' && !source?.uri) {
185
+ return resolveAssetSource(source.assetId)?.uri ?? undefined;
186
+ }
187
+ return source?.uri ?? undefined;
188
+ }
176
189
  export class AudioRecorderWeb extends globalThis.expo.SharedObject {
177
190
  constructor(options) {
178
191
  super();
@@ -1 +1 @@
1
- {"version":3,"file":"AudioModule.web.js","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAYzE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC9E,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;QACF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,QAAQ,KAAK,EAAE;YACb,KAAK,SAAS;gBACZ,OAAO,gBAAgB,CAAC,OAAO,CAAC;YAClC,KAAK,QAAQ;gBACX,OAAO,gBAAgB,CAAC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modules-core';\n\nimport {\n AudioMode,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n} from './Audio.types';\nimport { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';\nimport { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './ExpoAudio';\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 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 * 1000,\n currentTime: media.currentTime * 1000,\n playbackState: '',\n timeControlStatus: isPlaying ? 'playing' : 'paused',\n reasonForWaitingToPlay: '',\n playing: isPlaying,\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, interval: number) {\n super();\n this.src = source;\n this.interval = interval;\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 = 100;\n private isPlaying = false;\n private loaded = false;\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 * 1000;\n }\n\n get currentTime(): number {\n return this.media.currentTime * 1000;\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 this.src = source;\n this.media = this._createMediaElement();\n }\n\n async seekTo(seconds: number): Promise<void> {\n this.media.currentTime = seconds / 1000;\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(): HTMLAudioElement {\n const newSource = typeof this.src === 'string' ? this.src : (this.src?.uri ?? '');\n const media = new Audio(newSource);\n\n media.ontimeupdate = () => {\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n };\n\n media.onloadeddata = () => {\n this.loaded = true;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n isLoaded: this.loaded,\n });\n };\n\n return media;\n }\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(): 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 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(): RecordingInput {\n return {\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();\n this.timeoutIds.push(\n setTimeout(() => {\n this.stop();\n }, seconds * 1000)\n );\n }\n\n setInput(input: string): void {}\n\n startRecordingAtTime(seconds: number): void {\n this.timeoutIds.push(\n setTimeout(() => {\n this.record();\n }, seconds * 1000)\n );\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":"","s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KAAK,UAAU,qBAAqB,CAAC,MAAe,IAAG,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,MAAM,WAAW,GAAG,MAAM,2BAA2B,CAAC,YAAY,CAAC,CAAC;IACpE,QAAQ,WAAW,EAAE;QACnB,KAAK,gBAAgB,CAAC,OAAO;YAC3B,OAAO;gBACL,MAAM,EAAE,gBAAgB,CAAC,OAAO;gBAChC,OAAO,EAAE,OAAO;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;KACnD;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,IAAI;QACF,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;KACH;IAAC,MAAM;QACN,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,KAAK;SACf,CAAC;KACH;AACH,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus } from 'expo-modules-core';\n\nimport {\n AudioMode,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n} from './Audio.types';\nimport { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';\nimport { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './ExpoAudio';\nimport { RecordingPresets } from './RecordingConstants';\nimport resolveAssetSource from './utils/resolveAssetSource';\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 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 * 1000,\n currentTime: media.currentTime * 1000,\n playbackState: '',\n timeControlStatus: isPlaying ? 'playing' : 'paused',\n reasonForWaitingToPlay: '',\n playing: isPlaying,\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, interval: number) {\n super();\n this.src = source;\n this.interval = interval;\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 = 100;\n private isPlaying = false;\n private loaded = false;\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 * 1000;\n }\n\n get currentTime(): number {\n return this.media.currentTime * 1000;\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 this.src = source;\n this.media = this._createMediaElement();\n }\n\n async seekTo(seconds: number): Promise<void> {\n this.media.currentTime = seconds / 1000;\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(): HTMLAudioElement {\n const newSource = getSourceUri(this.src);\n const media = new Audio(newSource);\n\n media.ontimeupdate = () => {\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n };\n\n media.onloadeddata = () => {\n this.loaded = true;\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 return resolveAssetSource(source)?.uri ?? undefined;\n }\n if (typeof source?.assetId === 'number' && !source?.uri) {\n return resolveAssetSource(source.assetId)?.uri ?? undefined;\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(): 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 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(): RecordingInput {\n return {\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();\n this.timeoutIds.push(\n setTimeout(() => {\n this.stop();\n }, seconds * 1000)\n );\n }\n\n setInput(input: string): void {}\n\n startRecordingAtTime(seconds: number): void {\n this.timeoutIds.push(\n setTimeout(() => {\n this.record();\n }, seconds * 1000)\n );\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"]}
@@ -5,7 +5,7 @@ import { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';
5
5
  export declare const PLAYBACK_STATUS_UPDATE = "playbackStatusUpdate";
6
6
  export declare const AUDIO_SAMPLE_UPDATE = "audioSampleUpdate";
7
7
  export declare const RECORDING_STATUS_UPDATE = "recordingStatusUpdate";
8
- export declare function useAudioPlayer(source?: AudioSource | string | number | null, updateInterval?: number): AudioPlayer;
8
+ export declare function useAudioPlayer(source?: AudioSource, updateInterval?: number): AudioPlayer;
9
9
  export declare function useAudioPlayerStatus(player: AudioPlayer): AudioStatus;
10
10
  export declare function useAudioSampleListener(player: AudioPlayer, listener: (data: AudioSample) => void): void;
11
11
  export declare function useAudioRecorder(options: RecordingOptions, statusListener?: (status: RecordingStatus) => void): AudioRecorder;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoAudio.d.ts","sourceRoot":"","sources":["../src/ExpoAudio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAA4B,MAAM,mBAAmB,CAAC;AAGjF,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAI9E,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAC7D,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AACvD,eAAO,MAAM,uBAAuB,0BAA0B,CAAC;AAE/D,wBAAgB,cAAc,CAC5B,MAAM,GAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW,EACnD,cAAc,GAAE,MAAY,GAC3B,WAAW,CAMb;AAED,wBAAgB,oBAAoB,CAAC,MA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7D,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AACvD,eAAO,MAAM,uBAAuB,0BAA0B,CAAC;AAS/D,wBAAgB,cAAc,CAC5B,MAAM,GAAE,WAAkB,EAC1B,cAAc,GAAE,MAAY,GAC3B,WAAW,CAMb;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAGrE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,QAWhG;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GACjD,aAAa,CAcf;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,GAAE,MAAY,iBAYpF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW,EACnD,cAAc,GAAE,MAAY,GAC3B,WAAW,CAGb;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/E;AAED,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEpF;AAED,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEhF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -7,6 +7,12 @@ import { resolveSource } from './utils/resolveSource';
7
7
  export const PLAYBACK_STATUS_UPDATE = 'playbackStatusUpdate';
8
8
  export const AUDIO_SAMPLE_UPDATE = 'audioSampleUpdate';
9
9
  export const RECORDING_STATUS_UPDATE = 'recordingStatusUpdate';
10
+ // TODO: Temporary solution until we develop a way of overriding prototypes that won't break the lazy loading of the module.
11
+ const replace = AudioModule.AudioPlayer.prototype.replace;
12
+ AudioModule.AudioPlayer.prototype.replace = function (source) {
13
+ return replace.call(this, resolveSource(source));
14
+ };
15
+ // @docsMissing
10
16
  export function useAudioPlayer(source = null, updateInterval = 500) {
11
17
  const parsedSource = resolveSource(source);
12
18
  return useReleasingSharedObject(() => new AudioModule.AudioPlayer(parsedSource, updateInterval), [JSON.stringify(parsedSource)]);
@@ -16,11 +22,11 @@ export function useAudioPlayerStatus(player) {
16
22
  return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);
17
23
  }
18
24
  export function useAudioSampleListener(player, listener) {
19
- player.setAudioSamplingEnabled(true);
20
25
  useEffect(() => {
21
26
  if (!player.isAudioSamplingSupported) {
22
27
  return;
23
28
  }
29
+ player.setAudioSamplingEnabled(true);
24
30
  const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);
25
31
  return () => {
26
32
  subscription.remove();
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoAudio.js","sourceRoot":"","sources":["../src/ExpoAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAsB,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAUrD,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAE/D,MAAM,UAAU,cAAc,CAC5B,SAA+C,IAAI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,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, useReleasingSharedObject } from 'expo-modules-core';\nimport { useEffect, useState, useMemo } from 'react';\n\nimport {\n AudioMode,\n AudioSource,\n AudioStatus,\n RecorderState,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\nimport AudioModule from './AudioModule';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource } from './utils/resolveSource';\n\nexport const PLAYBACK_STATUS_UPDATE = 'playbackStatusUpdate';\nexport const AUDIO_SAMPLE_UPDATE = 'audioSampleUpdate';\nexport const RECORDING_STATUS_UPDATE = 'recordingStatusUpdate';\n\nexport function useAudioPlayer(\n source: AudioSource | string | number | null = null,\n updateInterval: number = 500\n): AudioPlayer {\n const parsedSource = resolveSource(source);\n return useReleasingSharedObject(\n () => new AudioModule.AudioPlayer(parsedSource, updateInterval),\n [JSON.stringify(parsedSource)]\n );\n}\n\nexport function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\nexport function useAudioSampleListener(player: AudioPlayer, listener: (data: AudioSample) => void) {\n player.setAudioSamplingEnabled(true);\n useEffect(() => {\n if (!player.isAudioSamplingSupported) {\n return;\n }\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => {\n subscription.remove();\n };\n }, [player.id]);\n}\n\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioRecorder {\n const platformOptions = createRecordingOptions(options);\n const recorder = useReleasingSharedObject(() => {\n return new AudioModule.AudioRecorder(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => subscription.remove();\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 setState(recorder.getStatus());\n }, interval);\n\n return () => clearInterval(int);\n }, [recorder.id]);\n\n return state;\n}\n\n/**\n * Creates an instance of an `AudioPlayer` that doesn't release automatically.\n *\n * > **info** For most use cases you should use the [`useAudioPlayer`](#useaudioplayersource-updateinterval) hook instead. See the [Using the `AudioPlayer` directly](#using-the-audioplayer-directly) section for more details.\n * @param source\n */\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n updateInterval: number = 500\n): AudioPlayer {\n const parsedSource = resolveSource(source);\n return new AudioModule.AudioPlayer(parsedSource, updateInterval);\n}\n\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\nexport async function setAudioModeAsync(mode: Partial<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.js","sourceRoot":"","sources":["../src/ExpoAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAsB,w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AAC,GAAG,EAAE;QACb,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE;YAC3B,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QACjC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAEb,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAA+C,IAAI,EACnD,iBAAyB,GAAG;IAE5B,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AACnE,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,IAAwB;IAC9D,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, useReleasingSharedObject } from 'expo-modules-core';\nimport { useEffect, useState, useMemo } from 'react';\n\nimport {\n AudioMode,\n AudioSource,\n AudioStatus,\n RecorderState,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\nimport AudioModule from './AudioModule';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource } from './utils/resolveSource';\n\nexport const PLAYBACK_STATUS_UPDATE = 'playbackStatusUpdate';\nexport const AUDIO_SAMPLE_UPDATE = 'audioSampleUpdate';\nexport const RECORDING_STATUS_UPDATE = 'recordingStatusUpdate';\n\n// TODO: Temporary solution until we develop a way of overriding prototypes that won't break the lazy loading of the module.\nconst replace = AudioModule.AudioPlayer.prototype.replace;\nAudioModule.AudioPlayer.prototype.replace = function (source: AudioSource) {\n return replace.call(this, resolveSource(source));\n};\n\n// @docsMissing\nexport function useAudioPlayer(\n source: AudioSource = null,\n updateInterval: number = 500\n): AudioPlayer {\n const parsedSource = resolveSource(source);\n return useReleasingSharedObject(\n () => new AudioModule.AudioPlayer(parsedSource, updateInterval),\n [JSON.stringify(parsedSource)]\n );\n}\n\nexport function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\nexport function useAudioSampleListener(player: AudioPlayer, listener: (data: AudioSample) => void) {\n useEffect(() => {\n if (!player.isAudioSamplingSupported) {\n return;\n }\n player.setAudioSamplingEnabled(true);\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => {\n subscription.remove();\n };\n }, [player.id]);\n}\n\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioRecorder {\n const platformOptions = createRecordingOptions(options);\n const recorder = useReleasingSharedObject(() => {\n return new AudioModule.AudioRecorder(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => subscription.remove();\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 setState(recorder.getStatus());\n }, interval);\n\n return () => clearInterval(int);\n }, [recorder.id]);\n\n return state;\n}\n\n/**\n * Creates an instance of an `AudioPlayer` that doesn't release automatically.\n *\n * > **info** For most use cases you should use the [`useAudioPlayer`](#useaudioplayersource-updateinterval) hook instead. See the [Using the `AudioPlayer` directly](#using-the-audioplayer-directly) section for more details.\n * @param source\n */\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n updateInterval: number = 500\n): AudioPlayer {\n const parsedSource = resolveSource(source);\n return new AudioModule.AudioPlayer(parsedSource, updateInterval);\n}\n\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\nexport async function setAudioModeAsync(mode: Partial<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"]}
@@ -4,5 +4,6 @@ export declare function createRecordingOptions(options: RecordingOptions): {
4
4
  sampleRate: number;
5
5
  numberOfChannels: number;
6
6
  bitRate: number;
7
+ isMeteringEnabled: boolean;
7
8
  };
8
9
  //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB;;;;;EAoB/D"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB;;;;;;EAqB/D"}
@@ -5,6 +5,7 @@ export function createRecordingOptions(options) {
5
5
  sampleRate: options.sampleRate,
6
6
  numberOfChannels: options.numberOfChannels,
7
7
  bitRate: options.bitRate,
8
+ isMeteringEnabled: options.isMeteringEnabled ?? false,
8
9
  };
9
10
  if (Platform.OS === 'ios') {
10
11
  commonOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,MAAM,UAAU,sBAAsB,CAAC,OAAyB;IAC9D,IAAI,aAAa,GAAG;QAClB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;IAEF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,aAAa,GAAG;YACd,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,GAAG;SACf,CAAC;KACH;SAAM,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QACpC,aAAa,GAAG;YACd,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,OAAO;SACnB,CAAC;KACH;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport { RecordingOptions } from '../Audio.types';\n\nexport function createRecordingOptions(options: RecordingOptions) {\n let commonOptions = {\n extension: options.extension,\n sampleRate: options.sampleRate,\n numberOfChannels: options.numberOfChannels,\n bitRate: options.bitRate,\n };\n\n if (Platform.OS === 'ios') {\n commonOptions = {\n ...commonOptions,\n ...options.ios,\n };\n } else if (Platform.OS === 'android') {\n commonOptions = {\n ...commonOptions,\n ...options.android,\n };\n }\n return commonOptions;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/utils/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,MAAM,UAAU,sBAAsB,CAAC,OAAyB;IAC9D,IAAI,aAAa,GAAG;QAClB,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;QACzB,aAAa,GAAG;YACd,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,GAAG;SACf,CAAC;KACH;SAAM,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QACpC,aAAa,GAAG;YACd,GAAG,aAAa;YAChB,GAAG,OAAO,CAAC,OAAO;SACnB,CAAC;KACH;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport { RecordingOptions } from '../Audio.types';\n\nexport function createRecordingOptions(options: RecordingOptions) {\n let commonOptions = {\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 commonOptions = {\n ...commonOptions,\n ...options.ios,\n };\n } else if (Platform.OS === 'android') {\n commonOptions = {\n ...commonOptions,\n ...options.android,\n };\n }\n return commonOptions;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export default function resolveAssetSource(assetId: number): {
2
+ uri: string;
3
+ } | null;
4
+ //# sourceMappingURL=resolveAssetSource.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAssetSource.web.d.ts","sourceRoot":"","sources":["../../src/utils/resolveAssetSource.web.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAYlF"}
@@ -0,0 +1,14 @@
1
+ import { getAssetByID } from '@react-native/assets-registry/registry';
2
+ export default function resolveAssetSource(assetId) {
3
+ const asset = getAssetByID(assetId);
4
+ if (!asset) {
5
+ return null;
6
+ }
7
+ const type = !asset.type ? '' : `.${asset.type}`;
8
+ const assetPath = __DEV__
9
+ ? asset.httpServerLocation + '/' + asset.name + type
10
+ : asset.httpServerLocation.replace(/\.\.\//g, '_') + '/' + asset.name + type;
11
+ const fromUrl = new URL(assetPath, 'https://expo.dev');
12
+ return { uri: fromUrl.toString().replace(fromUrl.origin, '') };
13
+ }
14
+ //# sourceMappingURL=resolveAssetSource.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAssetSource.web.js","sourceRoot":"","sources":["../../src/utils/resolveAssetSource.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,OAAe;IACxD,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IACD,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;IACjD,MAAM,SAAS,GAAG,OAAO;QACvB,CAAC,CAAC,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI;QACpD,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IAE/E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACvD,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;AACjE,CAAC","sourcesContent":["import { getAssetByID } from '@react-native/assets-registry/registry';\n\nexport default function resolveAssetSource(assetId: number): { uri: string } | null {\n const asset = getAssetByID(assetId);\n if (!asset) {\n return null;\n }\n const type = !asset.type ? '' : `.${asset.type}`;\n const assetPath = __DEV__\n ? asset.httpServerLocation + '/' + asset.name + type\n : asset.httpServerLocation.replace(/\\.\\.\\//g, '_') + '/' + asset.name + type;\n\n const fromUrl = new URL(assetPath, 'https://expo.dev');\n return { uri: fromUrl.toString().replace(fromUrl.origin, '') };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveSource.d.ts","sourceRoot":"","sources":["../../src/utils/resolveSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAQ/F"}
1
+ {"version":3,"file":"resolveSource.d.ts","sourceRoot":"","sources":["../../src/utils/resolveSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAQ/F"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveSource.js","sourceRoot":"","sources":["../../src/utils/resolveSource.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAGtD,MAAM,UAAU,aAAa,CAAC,MAA6C;IACzE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;KACxB;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;KACnC;IACD,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC","sourcesContent":["import resolveAssetSource from './resolveAssetSource';\nimport { AudioSource } from '../Audio.types';\n\nexport function resolveSource(source?: AudioSource | string | number | null): AudioSource | null {\n if (typeof source === 'string') {\n return { uri: source };\n }\n if (typeof source === 'number') {\n return resolveAssetSource(source);\n }\n return source ?? null;\n}\n"]}
1
+ {"version":3,"file":"resolveSource.js","sourceRoot":"","sources":["../../src/utils/resolveSource.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,MAAM,UAAU,aAAa,CAAC,MAA6C;IACzE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;KACxB;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;KACnC;IACD,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC","sourcesContent":["import { AudioSource } from '../Audio.types';\nimport resolveAssetSource from './resolveAssetSource';\n\nexport function resolveSource(source?: AudioSource | string | number | null): AudioSource | null {\n if (typeof source === 'string') {\n return { uri: source };\n }\n if (typeof source === 'number') {\n return resolveAssetSource(source);\n }\n return source ?? null;\n}\n"]}
@@ -91,12 +91,12 @@ public class AudioModule: Module {
91
91
  }
92
92
 
93
93
  Property("currentTime") { player in
94
- player.ref.currentItem?.currentTime().seconds
94
+ player.currentTime
95
95
  }
96
96
 
97
97
  Property("duration") { player in
98
98
  if player.ref.status == .readyToPlay {
99
- (player.ref.currentItem?.duration.seconds ?? 0.0) * 1000
99
+ player.duration
100
100
  } else {
101
101
  0.0
102
102
  }
@@ -141,7 +141,7 @@ public class AudioModule: Module {
141
141
  }
142
142
 
143
143
  Function("replace") { (player, source: AudioSource) in
144
- player.ref.replaceCurrentItem(with: AudioUtils.createAVPlayerItem(from: source))
144
+ player.replaceCurrentSource(source: source)
145
145
  }
146
146
 
147
147
  Function("pause") { player in
@@ -159,7 +159,7 @@ public class AudioModule: Module {
159
159
  AsyncFunction("seekTo") { (player: AudioPlayer, seconds: Double) in
160
160
  await player.ref.currentItem?.seek(
161
161
  to: CMTime(
162
- seconds: seconds / 1000,
162
+ seconds: seconds,
163
163
  preferredTimescale: CMTimeScale(NSEC_PER_SEC)
164
164
  )
165
165
  )
@@ -25,9 +25,14 @@ public class AudioPlayer: SharedRef<AVPlayer> {
25
25
  private var audioProcessor: AudioTapProcessor?
26
26
  private var samplingEnabled = false
27
27
  private var tapInstalled = false
28
+ private var shouldInstallAudioTap = false
28
29
 
29
- private var duration: Double {
30
- (ref.currentItem?.duration.seconds ?? 0.0) * 1000
30
+ var duration: Double {
31
+ ref.currentItem?.duration.seconds ?? 0.0
32
+ }
33
+
34
+ var currentTime: Double {
35
+ ref.currentItem?.currentTime().seconds ?? 0.0
31
36
  }
32
37
 
33
38
  init(_ ref: AVPlayer, interval: Double) {
@@ -65,15 +70,15 @@ public class AudioPlayer: SharedRef<AVPlayer> {
65
70
  }
66
71
 
67
72
  func currentStatus() -> [String: Any] {
68
- let duration = ref.status == .readyToPlay ? duration : 0.0
73
+ let currentDuration = ref.status == .readyToPlay ? duration : 0.0
69
74
  return [
70
75
  "id": id,
71
- "currentTime": (ref.currentItem?.currentTime().seconds ?? 0) * 1000,
76
+ "currentTime": currentTime,
72
77
  "playbackState": statusToString(status: ref.status),
73
78
  "timeControlStatus": timeControlStatusString(status: ref.timeControlStatus),
74
79
  "reasonForWaitingToPlay": reasonForWaitingToPlayString(status: ref.reasonForWaitingToPlay),
75
80
  "mute": ref.isMuted,
76
- "duration": duration,
81
+ "duration": currentDuration,
77
82
  "playing": ref.timeControlStatus == .playing,
78
83
  "loop": isLooping,
79
84
  "isLoaded": ref.currentItem?.status == .readyToPlay,
@@ -93,19 +98,42 @@ public class AudioPlayer: SharedRef<AVPlayer> {
93
98
 
94
99
  private func setupPublisher() {
95
100
  ref.publisher(for: \.currentItem?.status)
96
- .sink { status in
97
- guard let status else {
101
+ .sink { [weak self] status in
102
+ guard let self, let status else {
98
103
  return
99
104
  }
100
105
  if status == .readyToPlay {
101
106
  self.updateStatus(with: [
102
107
  "isLoaded": true
103
108
  ])
109
+ // We can't add the audio tap until the asset has loaded, otherwise the asset track will be empty.
110
+ // This is particularly important after replacing the audio source
111
+ if shouldInstallAudioTap {
112
+ setSamplingEnabled(enabled: shouldInstallAudioTap)
113
+ shouldInstallAudioTap = false
114
+ }
104
115
  }
105
116
  }
106
117
  .store(in: &cancellables)
107
118
  }
108
119
 
120
+ func replaceCurrentSource(source: AudioSource) {
121
+ let wasPlaying = ref.timeControlStatus == .playing
122
+ let wasSamplingEnabled = samplingEnabled
123
+ ref.pause()
124
+
125
+ // Remove the audio tap if it is active
126
+ if samplingEnabled {
127
+ setSamplingEnabled(enabled: false)
128
+ }
129
+ ref.replaceCurrentItem(with: AudioUtils.createAVPlayerItem(from: source))
130
+ shouldInstallAudioTap = wasSamplingEnabled
131
+
132
+ if wasPlaying {
133
+ ref.play()
134
+ }
135
+ }
136
+
109
137
  private func playerIsBuffering() -> Bool {
110
138
  if ref.timeControlStatus == .playing {
111
139
  return false
@@ -122,8 +150,8 @@ public class AudioPlayer: SharedRef<AVPlayer> {
122
150
  }
123
151
 
124
152
  private func installTap() {
125
- if let item = ref.currentItem, !tapInstalled {
126
- audioProcessor = AudioTapProcessor(playerItem: item)
153
+ if !tapInstalled {
154
+ audioProcessor = AudioTapProcessor(player: ref)
127
155
  tapInstalled = audioProcessor?.installTap() ?? false
128
156
  audioProcessor?.sampleBufferCallback = { [weak self] buffer, frameCount, timestamp in
129
157
  guard let self,
@@ -183,7 +211,7 @@ public class AudioPlayer: SharedRef<AVPlayer> {
183
211
  let interval = CMTime(seconds: updateInterval, preferredTimescale: CMTimeScale(NSEC_PER_SEC))
184
212
  timeToken = ref.addPeriodicTimeObserver(forInterval: interval, queue: nil) { time in
185
213
  self.updateStatus(with: [
186
- "currentTime": time.seconds * 1000
214
+ "currentTime": time.seconds
187
215
  ])
188
216
  }
189
217
  }
@@ -50,6 +50,9 @@ class AudioRecorder: SharedRef<AVAudioRecorder>, RecordingResultHandler {
50
50
  ref = AudioUtils.createRecorder(directory: recordingDirectory, with: options)
51
51
  ref.delegate = recordingDelegate
52
52
  }
53
+ if let isMeteringEnabled = options?.isMeteringEnabled {
54
+ ref.isMeteringEnabled = isMeteringEnabled
55
+ }
53
56
  ref.prepareToRecord()
54
57
  isPrepared = true
55
58
  }
@@ -42,6 +42,7 @@ struct RecordingOptions: Record {
42
42
  @Field var linearPCMBitDepth: Double?
43
43
  @Field var linearPCMIsBigEndian: Bool?
44
44
  @Field var linearPCMIsFloat: Bool?
45
+ @Field var isMeteringEnabled: Bool = false
45
46
  }
46
47
 
47
48
  enum BitRateStrategy: String, Enumerable {
@@ -6,9 +6,9 @@ typedef void (^SampleBufferCallback)(AudioBuffer *audioBuffer, long frameCount,
6
6
  @interface AudioTapProcessor : NSObject
7
7
 
8
8
  @property (nonatomic, copy) SampleBufferCallback sampleBufferCallback;
9
- @property (nonatomic, strong) AVPlayerItem *playerItem;
9
+ @property (nonatomic, strong) AVPlayer *player;
10
10
 
11
- - (instancetype)initWithPlayerItem:(AVPlayerItem *)playerItem;
11
+ - (instancetype)initWithPlayer:(AVPlayer *)player;
12
12
  - (bool)installTap;
13
13
  - (void)uninstallTap;
14
14
 
@@ -14,20 +14,20 @@ typedef struct AVAudioTapProcessorContext {
14
14
 
15
15
  @implementation AudioTapProcessor
16
16
 
17
- - (instancetype)initWithPlayerItem:(AVPlayerItem *)playerItem {
17
+ - (instancetype)initWithPlayer:(AVPlayer *)player {
18
18
  self = [super init];
19
19
  if (self) {
20
- _playerItem = playerItem;
20
+ _player = player;
21
21
  }
22
22
  return self;
23
23
  }
24
24
 
25
25
  - (bool)installTap {
26
- if (!_playerItem) {
26
+ if (![_player currentItem]) {
27
27
  return false;
28
28
  }
29
29
 
30
- AVAssetTrack *track = _playerItem.tracks.firstObject.assetTrack;
30
+ AVAssetTrack *track = _player.currentItem.tracks.firstObject.assetTrack;
31
31
  if (!track) {
32
32
  return false;
33
33
  }
@@ -50,7 +50,7 @@ typedef struct AVAudioTapProcessorContext {
50
50
  if (status == noErr) {
51
51
  audioMixInputParameters.audioTapProcessor = audioProcessingTap;
52
52
  audioMix.inputParameters = @[audioMixInputParameters];
53
- [_playerItem setAudioMix:audioMix];
53
+ [_player.currentItem setAudioMix:audioMix];
54
54
  CFRelease(audioProcessingTap);
55
55
  } else {
56
56
  return false;
@@ -61,7 +61,7 @@ typedef struct AVAudioTapProcessorContext {
61
61
  }
62
62
 
63
63
  - (void)uninstallTap {
64
- [_playerItem setAudioMix:nil];
64
+ [_player.currentItem setAudioMix:nil];
65
65
  }
66
66
 
67
67
  #pragma mark - Audio Sample Buffer Callbacks (MTAudioProcessingTapCallbacks)
@@ -103,8 +103,8 @@ void tapUnprepare(MTAudioProcessingTapRef tap) {
103
103
 
104
104
  void tapProcess(MTAudioProcessingTapRef tap, CMItemCount numberFrames, MTAudioProcessingTapFlags flags, AudioBufferList *bufferListInOut, CMItemCount *numberFramesOut, MTAudioProcessingTapFlags *flagsOut) {
105
105
  AVAudioTapProcessorContext *context = (AVAudioTapProcessorContext *)MTAudioProcessingTapGetStorage(tap);
106
- if (!context->self) {
107
- NSLog(@"Audio Processing Tap has been destroyed!");
106
+ if (!context || !context->self) {
107
+ NSLog(@"Audio Processing Tap storage or context is invalid!");
108
108
  return;
109
109
  }
110
110
 
@@ -114,12 +114,12 @@ void tapProcess(MTAudioProcessingTapRef tap, CMItemCount numberFrames, MTAudioPr
114
114
  }
115
115
 
116
116
  OSStatus status = MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut, flagsOut, NULL, numberFramesOut);
117
- if (noErr != status) {
117
+ if (status != noErr) {
118
118
  NSLog(@"MTAudioProcessingTapGetSourceAudio: %d", (int)status);
119
119
  return;
120
120
  }
121
121
 
122
- double seconds = CMTimeGetSeconds([_self->_playerItem currentTime]);
122
+ double seconds = CMTimeGetSeconds([_self->_player.currentItem currentTime]);
123
123
  _self.sampleBufferCallback(&bufferListInOut->mBuffers[0], numberFrames, seconds);
124
124
  }
125
125
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-audio",
3
3
  "title": "Expo Audio",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
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",
@@ -40,5 +40,5 @@
40
40
  "react": "*",
41
41
  "react-native": "*"
42
42
  },
43
- "gitHead": "bc1fea6bcab47889e2922d543920397691b200f3"
43
+ "gitHead": "1955c7d38e69c0eb62df89d516a392ea64db6405"
44
44
  }
@@ -1,18 +1,24 @@
1
1
  export type AudioSource =
2
2
  | string
3
+ | number
4
+ | null
3
5
  | {
4
6
  /**
5
7
  * A string representing the resource identifier for the audio,
6
8
  * which could be an HTTPS address, a local file path, or the name of a static audio file resource.
7
9
  */
8
10
  uri?: string;
11
+ /**
12
+ * The asset ID of a local audio asset, acquired with the `require` function.
13
+ * This property is exclusive with the `uri` property. When both are present, the `assetId` will be ignored.
14
+ */
15
+ assetId?: number;
9
16
  /**
10
17
  * An object representing the HTTP headers to send along with the request for a remote audio source.
11
18
  * On web requires the `Access-Control-Allow-Origin` header returned by the server to include the current domain.
12
19
  */
13
20
  headers?: Record<string, string>;
14
- }
15
- | null;
21
+ };
16
22
 
17
23
  export type RecordingInput = {
18
24
  name: string;
@@ -115,6 +121,10 @@ export enum AudioQuality {
115
121
  export type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';
116
122
 
117
123
  export type RecordingOptions = {
124
+ /**
125
+ * A boolean that determines whether audio level information will be part of the status object under the "metering" key.
126
+ */
127
+ isMeteringEnabled?: boolean;
118
128
  /**
119
129
  * The desired file extension.
120
130
  *
@@ -1,4 +1,4 @@
1
- import { PermissionResponse, SharedObject } from 'expo-modules-core';
1
+ import { NativeModule, PermissionResponse, SharedObject } from 'expo-modules-core';
2
2
 
3
3
  import {
4
4
  AudioMode,
@@ -14,7 +14,7 @@ import {
14
14
  /**
15
15
  * @hidden
16
16
  */
17
- export declare class NativeAudioModule {
17
+ export declare class NativeAudioModule extends NativeModule {
18
18
  setIsAudioActiveAsync(active: boolean): Promise<void>;
19
19
  setAudioModeAsync(category: Partial<AudioMode>): Promise<void>;
20
20
  requestRecordingPermissionsAsync(): Promise<PermissionResponse>;
@@ -72,7 +72,7 @@ export declare class AudioPlayer extends SharedObject<AudioEvents> {
72
72
  isBuffering: boolean;
73
73
 
74
74
  /**
75
- * The current position through the audio item, in seconds.
75
+ * The current position through the audio item in seconds.
76
76
  */
77
77
  currentTime: number;
78
78
 
@@ -12,6 +12,7 @@ import {
12
12
  import { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';
13
13
  import { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './ExpoAudio';
14
14
  import { RecordingPresets } from './RecordingConstants';
15
+ import resolveAssetSource from './utils/resolveAssetSource';
15
16
 
16
17
  const nextId = (() => {
17
18
  let id = 0;
@@ -209,7 +210,7 @@ export class AudioPlayerWeb
209
210
  }
210
211
 
211
212
  _createMediaElement(): HTMLAudioElement {
212
- const newSource = typeof this.src === 'string' ? this.src : (this.src?.uri ?? '');
213
+ const newSource = getSourceUri(this.src);
213
214
  const media = new Audio(newSource);
214
215
 
215
216
  media.ontimeupdate = () => {
@@ -228,6 +229,20 @@ export class AudioPlayerWeb
228
229
  }
229
230
  }
230
231
 
232
+ function getSourceUri(source: AudioSource): string | undefined {
233
+ if (typeof source === 'string') {
234
+ return source;
235
+ }
236
+ if (typeof source === 'number') {
237
+ return resolveAssetSource(source)?.uri ?? undefined;
238
+ }
239
+ if (typeof source?.assetId === 'number' && !source?.uri) {
240
+ return resolveAssetSource(source.assetId)?.uri ?? undefined;
241
+ }
242
+
243
+ return source?.uri ?? undefined;
244
+ }
245
+
231
246
  export class AudioRecorderWeb
232
247
  extends globalThis.expo.SharedObject<RecordingEvents>
233
248
  implements AudioRecorder
package/src/ExpoAudio.ts CHANGED
@@ -19,8 +19,15 @@ export const PLAYBACK_STATUS_UPDATE = 'playbackStatusUpdate';
19
19
  export const AUDIO_SAMPLE_UPDATE = 'audioSampleUpdate';
20
20
  export const RECORDING_STATUS_UPDATE = 'recordingStatusUpdate';
21
21
 
22
+ // TODO: Temporary solution until we develop a way of overriding prototypes that won't break the lazy loading of the module.
23
+ const replace = AudioModule.AudioPlayer.prototype.replace;
24
+ AudioModule.AudioPlayer.prototype.replace = function (source: AudioSource) {
25
+ return replace.call(this, resolveSource(source));
26
+ };
27
+
28
+ // @docsMissing
22
29
  export function useAudioPlayer(
23
- source: AudioSource | string | number | null = null,
30
+ source: AudioSource = null,
24
31
  updateInterval: number = 500
25
32
  ): AudioPlayer {
26
33
  const parsedSource = resolveSource(source);
@@ -36,11 +43,11 @@ export function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {
36
43
  }
37
44
 
38
45
  export function useAudioSampleListener(player: AudioPlayer, listener: (data: AudioSample) => void) {
39
- player.setAudioSamplingEnabled(true);
40
46
  useEffect(() => {
41
47
  if (!player.isAudioSamplingSupported) {
42
48
  return;
43
49
  }
50
+ player.setAudioSamplingEnabled(true);
44
51
  const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);
45
52
  return () => {
46
53
  subscription.remove();
@@ -8,6 +8,7 @@ export function createRecordingOptions(options: RecordingOptions) {
8
8
  sampleRate: options.sampleRate,
9
9
  numberOfChannels: options.numberOfChannels,
10
10
  bitRate: options.bitRate,
11
+ isMeteringEnabled: options.isMeteringEnabled ?? false,
11
12
  };
12
13
 
13
14
  if (Platform.OS === 'ios') {
@@ -0,0 +1,15 @@
1
+ import { getAssetByID } from '@react-native/assets-registry/registry';
2
+
3
+ export default function resolveAssetSource(assetId: number): { uri: string } | null {
4
+ const asset = getAssetByID(assetId);
5
+ if (!asset) {
6
+ return null;
7
+ }
8
+ const type = !asset.type ? '' : `.${asset.type}`;
9
+ const assetPath = __DEV__
10
+ ? asset.httpServerLocation + '/' + asset.name + type
11
+ : asset.httpServerLocation.replace(/\.\.\//g, '_') + '/' + asset.name + type;
12
+
13
+ const fromUrl = new URL(assetPath, 'https://expo.dev');
14
+ return { uri: fromUrl.toString().replace(fromUrl.origin, '') };
15
+ }
@@ -1,5 +1,5 @@
1
- import resolveAssetSource from './resolveAssetSource';
2
1
  import { AudioSource } from '../Audio.types';
2
+ import resolveAssetSource from './resolveAssetSource';
3
3
 
4
4
  export function resolveSource(source?: AudioSource | string | number | null): AudioSource | null {
5
5
  if (typeof source === 'string') {