expo-audio 0.4.1 → 0.4.3

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 (63) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/audio/AudioModule.kt +95 -4
  4. package/android/src/main/java/expo/modules/audio/AudioPlayer.kt +1 -1
  5. package/android/src/main/java/expo/modules/audio/AudioRecords.kt +7 -1
  6. package/build/Audio.types.d.ts +7 -0
  7. package/build/Audio.types.d.ts.map +1 -1
  8. package/build/Audio.types.js.map +1 -1
  9. package/build/AudioModule.web.d.ts.map +1 -1
  10. package/build/AudioModule.web.js +4 -0
  11. package/build/AudioModule.web.js.map +1 -1
  12. package/build/ExpoAudio.d.ts.map +1 -1
  13. package/build/ExpoAudio.js +1 -0
  14. package/build/ExpoAudio.js.map +1 -1
  15. package/expo-module.config.json +1 -1
  16. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar +0 -0
  17. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.md5 +1 -0
  18. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.sha1 +1 -0
  19. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.sha256 +1 -0
  20. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.sha512 +1 -0
  21. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar +0 -0
  22. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.md5 +1 -0
  23. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.sha1 +1 -0
  24. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.sha256 +1 -0
  25. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.sha512 +1 -0
  26. package/local-maven-repo/expo/modules/audio/expo.modules.audio/{0.4.1/expo.modules.audio-0.4.1.module → 0.4.3/expo.modules.audio-0.4.3.module} +22 -22
  27. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.md5 +1 -0
  28. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.sha1 +1 -0
  29. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.sha256 +1 -0
  30. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.sha512 +1 -0
  31. package/local-maven-repo/expo/modules/audio/expo.modules.audio/{0.4.1/expo.modules.audio-0.4.1.pom → 0.4.3/expo.modules.audio-0.4.3.pom} +1 -1
  32. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.md5 +1 -0
  33. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.sha1 +1 -0
  34. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.sha256 +1 -0
  35. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.sha512 +1 -0
  36. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml +4 -4
  37. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.md5 +1 -1
  38. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha1 +1 -1
  39. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha256 +1 -1
  40. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha512 +1 -1
  41. package/package.json +3 -3
  42. package/src/Audio.types.ts +9 -0
  43. package/src/AudioModule.web.ts +4 -0
  44. package/src/ExpoAudio.ts +1 -0
  45. package/src/ts-declarations/react-native-assets.d.ts +1 -0
  46. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1-sources.jar +0 -0
  47. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1-sources.jar.md5 +0 -1
  48. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1-sources.jar.sha1 +0 -1
  49. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1-sources.jar.sha256 +0 -1
  50. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1-sources.jar.sha512 +0 -1
  51. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.aar +0 -0
  52. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.aar.md5 +0 -1
  53. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.aar.sha1 +0 -1
  54. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.aar.sha256 +0 -1
  55. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.aar.sha512 +0 -1
  56. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.module.md5 +0 -1
  57. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.module.sha1 +0 -1
  58. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.module.sha256 +0 -1
  59. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.module.sha512 +0 -1
  60. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.pom.md5 +0 -1
  61. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.pom.sha1 +0 -1
  62. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.pom.sha256 +0 -1
  63. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.1/expo.modules.audio-0.4.1.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.4.3 — 2025-04-25
14
+
15
+ ### 💡 Others
16
+
17
+ - [Android] Support manual audio focus control on `Android`. ([#36221](https://github.com/expo/expo/pull/36221) by [@alanjhughes](https://github.com/alanjhughes))
18
+
19
+ ## 0.4.2 — 2025-04-14
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 0.4.1 — 2025-04-09
14
24
 
15
25
  _This version does not introduce any user-facing changes._
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'expo.modules.audio'
7
- version = '0.4.1'
7
+ version = '0.4.3'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.audio"
11
11
  defaultConfig {
12
12
  versionCode 1
13
- versionName "0.4.1"
13
+ versionName "0.4.3"
14
14
  }
15
15
 
16
16
  compileOptions {
@@ -3,8 +3,11 @@ package expo.modules.audio
3
3
  import android.Manifest
4
4
  import android.content.Context
5
5
  import android.content.pm.PackageManager
6
+ import android.media.AudioAttributes
7
+ import android.media.AudioFocusRequest
6
8
  import android.media.AudioManager
7
9
  import android.net.Uri
10
+ import android.os.Build
8
11
  import android.util.Log
9
12
  import androidx.core.content.ContextCompat
10
13
  import androidx.media3.common.C.CONTENT_TYPE_DASH
@@ -49,6 +52,83 @@ class AudioModule : Module() {
49
52
  private var staysActiveInBackground = false
50
53
  private var audioEnabled = true
51
54
  private var shouldRouteThroughEarpiece = false
55
+ private var focusAcquired = false
56
+ private var interruptionMode: InterruptionMode? = null
57
+
58
+ private var audioFocusRequest: AudioFocusRequest? = null
59
+ private val audioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { focusChange ->
60
+ when (focusChange) {
61
+ AudioManager.AUDIOFOCUS_LOSS,
62
+ AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
63
+ focusAcquired = false
64
+ players.values.forEach {
65
+ it.player.pause()
66
+ }
67
+ }
68
+
69
+ AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
70
+ focusAcquired = false
71
+ if (interruptionMode == InterruptionMode.DUCK_OTHERS) {
72
+ players.values.forEach {
73
+ it.player.volume /= 2f
74
+ }
75
+ }
76
+ }
77
+
78
+ AudioManager.AUDIOFOCUS_GAIN -> {
79
+ focusAcquired = true
80
+ players.values.forEach {
81
+ it.setVolume(it.previousVolume)
82
+ }
83
+ }
84
+ }
85
+ }
86
+
87
+ private fun requestAudioFocus() {
88
+ if (focusAcquired || !audioEnabled) {
89
+ return
90
+ }
91
+
92
+ val result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
93
+ val requestType = interruptionMode?.let {
94
+ if (it == InterruptionMode.DO_NOT_MIX) {
95
+ AudioManager.AUDIOFOCUS_GAIN
96
+ } else {
97
+ AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
98
+ }
99
+ } ?: AudioManager.AUDIOFOCUS_GAIN
100
+ val audioFocusRequest = AudioFocusRequest.Builder(requestType).run {
101
+ setAudioAttributes(
102
+ AudioAttributes.Builder()
103
+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
104
+ .build()
105
+ )
106
+ setAcceptsDelayedFocusGain(true)
107
+ setOnAudioFocusChangeListener(audioFocusChangeListener)
108
+ build()
109
+ }
110
+ audioFocusRequest?.let {
111
+ audioManager.requestAudioFocus(it)
112
+ }
113
+ } else {
114
+ audioManager.requestAudioFocus(audioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN)
115
+ }
116
+
117
+ if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
118
+ Log.e(TAG, "Audio focus request failed")
119
+ }
120
+ }
121
+
122
+ private fun releaseAudioFocus() {
123
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
124
+ audioFocusRequest?.let {
125
+ audioManager.abandonAudioFocusRequest(it)
126
+ }
127
+ } else {
128
+ audioManager.abandonAudioFocus(audioFocusChangeListener)
129
+ }
130
+ focusAcquired = false
131
+ }
52
132
 
53
133
  override fun definition() = ModuleDefinition {
54
134
  Name("ExpoAudio")
@@ -59,6 +139,7 @@ class AudioModule : Module() {
59
139
 
60
140
  AsyncFunction("setAudioModeAsync") { mode: AudioMode ->
61
141
  staysActiveInBackground = mode.shouldPlayInBackground
142
+ interruptionMode = mode.interruptionMode
62
143
  updatePlaySoundThroughEarpiece(mode.shouldRouteThroughEarpiece ?: false)
63
144
  }
64
145
 
@@ -70,6 +151,7 @@ class AudioModule : Module() {
70
151
  if (it.player.isPlaying) {
71
152
  it.player.pause()
72
153
  }
154
+ releaseAudioFocus()
73
155
  }
74
156
  }
75
157
  }
@@ -87,6 +169,7 @@ class AudioModule : Module() {
87
169
  if (!appIsPaused) {
88
170
  appIsPaused = true
89
171
  if (!staysActiveInBackground) {
172
+ releaseAudioFocus()
90
173
  players.values.forEach { player ->
91
174
  if (player.player.isPlaying) {
92
175
  player.isPaused = true
@@ -107,6 +190,7 @@ class AudioModule : Module() {
107
190
  if (appIsPaused) {
108
191
  appIsPaused = false
109
192
  if (!staysActiveInBackground) {
193
+ requestAudioFocus()
110
194
  players.values.forEach { player ->
111
195
  if (player.isPaused) {
112
196
  player.isPaused = false
@@ -129,12 +213,13 @@ class AudioModule : Module() {
129
213
 
130
214
  OnDestroy {
131
215
  appContext.mainQueue.launch {
132
- for (player in players.values) {
133
- player.player.stop()
216
+ releaseAudioFocus()
217
+ players.values.forEach {
218
+ it.player.stop()
134
219
  }
135
220
 
136
- for (recorder in recorders.values) {
137
- recorder.stopRecording()
221
+ recorders.values.forEach {
222
+ it.stopRecording()
138
223
  }
139
224
  }
140
225
  }
@@ -246,6 +331,9 @@ class AudioModule : Module() {
246
331
  return@Function
247
332
  }
248
333
  runOnMain {
334
+ if (!focusAcquired && players.values.any { it.player.isPlaying }) {
335
+ requestAudioFocus()
336
+ }
249
337
  ref.player.play()
250
338
  }
251
339
  }
@@ -264,6 +352,9 @@ class AudioModule : Module() {
264
352
  mediaSource?.let {
265
353
  ref.setMediaSource(it)
266
354
  if (wasPlaying) {
355
+ if (!focusAcquired) {
356
+ requestAudioFocus()
357
+ }
267
358
  ref.player.play()
268
359
  }
269
360
  }
@@ -39,6 +39,7 @@ class AudioPlayer(
39
39
  ) : SharedRef<ExoPlayer>(
40
40
  ExoPlayer.Builder(context)
41
41
  .setLooper(context.mainLooper)
42
+ .setAudioAttributes(AudioAttributes.DEFAULT, false)
42
43
  .build(),
43
44
  appContext
44
45
  ) {
@@ -60,7 +61,6 @@ class AudioPlayer(
60
61
  val duration get() = if (player.duration != C.TIME_UNSET) player.duration / 1000f else 0f
61
62
 
62
63
  init {
63
- player.setAudioAttributes(AudioAttributes.DEFAULT, true)
64
64
  addPlayerListeners()
65
65
  source?.let {
66
66
  setMediaSource(source)
@@ -13,7 +13,8 @@ class AudioSource(
13
13
 
14
14
  class AudioMode(
15
15
  @Field val shouldPlayInBackground: Boolean = false,
16
- @Field val shouldRouteThroughEarpiece: Boolean?
16
+ @Field val shouldRouteThroughEarpiece: Boolean?,
17
+ @Field val interruptionMode: InterruptionMode?
17
18
  ) : Record
18
19
 
19
20
  // Data class because we want `equals`
@@ -75,3 +76,8 @@ enum class AndroidAudioEncoder(val value: String) : Enumerable {
75
76
  AAC_ELD -> MediaRecorder.AudioEncoder.AAC_ELD
76
77
  }
77
78
  }
79
+
80
+ enum class InterruptionMode(val value: String) : Enumerable {
81
+ DO_NOT_MIX("doNotMix"),
82
+ DUCK_OTHERS("duckOthers")
83
+ }
@@ -254,6 +254,12 @@ export type AudioMode = {
254
254
  * @platform ios
255
255
  */
256
256
  interruptionMode: InterruptionMode;
257
+ /**
258
+ * Determines how the audio session interacts with other sessions on Android.
259
+ *
260
+ * @platform android
261
+ */
262
+ interruptionModeAndroid: InterruptionModeAndroid;
257
263
  /**
258
264
  * Whether the audio session allows recording.
259
265
  *
@@ -273,4 +279,5 @@ export type AudioMode = {
273
279
  shouldRouteThroughEarpiece: boolean;
274
280
  };
275
281
  export type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';
282
+ export type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';
276
283
  //# sourceMappingURL=Audio.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Audio.types.d.ts","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,MAAM,GACN,IAAI,GACJ;IACE;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAG/D,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO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uB,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,eAAe;AACf,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":["// @docsMissing\nexport type AudioSource =\n | string\n | number\n | null\n | {\n /**\n * A string representing the resource identifier for the audio,\n * which could be an HTTPS address, a local file path, or the name of a static audio file resource.\n */\n uri?: string;\n /**\n * The asset ID of a local audio asset, acquired with the `require` function.\n * This property is exclusive with the `uri` property. When both are present, the `assetId` will be ignored.\n */\n assetId?: number;\n /**\n * An object representing the HTTP headers to send along with the request for a remote audio source.\n * On web requires the `Access-Control-Allow-Origin` header returned by the server to include the current domain.\n */\n headers?: Record<string, string>;\n };\n\nexport type RecordingInput = {\n name: string;\n type: string;\n uid: string;\n};\n\n// @docsMissing\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\n// @docsMissing\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 didJustFinish: boolean;\n isBuffering: boolean;\n isLoaded: boolean;\n playbackRate: number;\n shouldCorrectPitch: boolean;\n};\n\n// @docsMissing\nexport type RecordingStatus = {\n id: number;\n isFinished: boolean;\n hasError: boolean;\n error: string | null;\n url: string | null;\n};\n\n// @docsMissing\nexport type RecorderState = {\n canRecord: boolean;\n isRecording: boolean;\n durationMillis: number;\n mediaServicesDidReset: boolean;\n metering?: number;\n url: string | null;\n};\n\n// @docsMissing\n/**\n * @platform android\n */\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\n// @docsMissing\n/**\n * @platform android\n */\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\n// @docsMissing\n/**\n * @platform ios\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\n// @docsMissing\nexport enum AudioQuality {\n MIN = 0,\n LOW = 0x20,\n MEDIUM = 0x40,\n HIGH = 0x60,\n MAX = 0x7f,\n}\n\n// @docsMissing\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 * @platform android\n */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n * @platform ios\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n * @platform web\n */\n web?: RecordingOptionsWeb;\n};\n\n// @docsMissing\n/**\n * @platform web\n */\nexport type RecordingOptionsWeb = {\n mimeType?: string;\n bitsPerSecond?: number;\n};\n\n// @docsMissing\n/**\n * @platform ios\n */\nexport type RecordingOptionsIos = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.\n */\n outputFormat?: string | IOSOutputFormat | number;\n /**\n * The desired audio quality. See the [`AudioQuality`](#audioquality) enum for all valid values.\n */\n audioQuality: AudioQuality | number;\n /**\n * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.\n */\n bitRateStrategy?: number;\n /**\n * The desired bit depth hint.\n *\n * @example 16\n */\n bitDepthHint?: number;\n /**\n * The desired PCM bit depth.\n *\n * @example 16\n */\n linearPCMBitDepth?: number;\n /**\n * A boolean describing if the PCM data should be formatted in big endian.\n */\n linearPCMIsBigEndian?: boolean;\n /**\n * A boolean describing if the PCM data should be encoded in floating point or integral values.\n */\n linearPCMIsFloat?: boolean;\n};\n\n// @docsMissing\n/**\n * @platform android\n */\nexport type RecordingOptionsAndroid = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.\n */\n outputFormat: AndroidOutputFormat;\n /**\n * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.\n */\n audioEncoder: AndroidAudioEncoder;\n /**\n * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still\n * be called after this point).\n *\n * @example\n * `65536`\n */\n maxFileSize?: number;\n};\n\nexport type AudioMode = {\n /**\n * Determines if audio playback is allowed when the device is in silent mode.\n *\n * @platform ios\n */\n playsInSilentMode: boolean;\n /**\n * Determines how the audio session interacts with other sessions.\n *\n * @platform ios\n */\n interruptionMode: InterruptionMode;\n /**\n * Whether the audio session allows recording.\n *\n * @default false\n * @platform ios\n */\n allowsRecording: boolean;\n /**\n * Whether the audio session stays active when the app moves to the background.\n * @default false\n */\n shouldPlayInBackground: boolean;\n /**\n * Whether the audio should route through the earpiece.\n * @platform android\n */\n shouldRouteThroughEarpiece: boolean;\n};\n\n// @docsMissing\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n"]}
1
+ {"version":3,"file":"Audio.types.js","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"AAyFA,eAAe;AACf;;GAEG;AACH,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,eAAe;AACf,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":["// @docsMissing\nexport type AudioSource =\n | string\n | number\n | null\n | {\n /**\n * A string representing the resource identifier for the audio,\n * which could be an HTTPS address, a local file path, or the name of a static audio file resource.\n */\n uri?: string;\n /**\n * The asset ID of a local audio asset, acquired with the `require` function.\n * This property is exclusive with the `uri` property. When both are present, the `assetId` will be ignored.\n */\n assetId?: number;\n /**\n * An object representing the HTTP headers to send along with the request for a remote audio source.\n * On web requires the `Access-Control-Allow-Origin` header returned by the server to include the current domain.\n */\n headers?: Record<string, string>;\n };\n\nexport type RecordingInput = {\n name: string;\n type: string;\n uid: string;\n};\n\n// @docsMissing\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\n// @docsMissing\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 didJustFinish: boolean;\n isBuffering: boolean;\n isLoaded: boolean;\n playbackRate: number;\n shouldCorrectPitch: boolean;\n};\n\n// @docsMissing\nexport type RecordingStatus = {\n id: number;\n isFinished: boolean;\n hasError: boolean;\n error: string | null;\n url: string | null;\n};\n\n// @docsMissing\nexport type RecorderState = {\n canRecord: boolean;\n isRecording: boolean;\n durationMillis: number;\n mediaServicesDidReset: boolean;\n metering?: number;\n url: string | null;\n};\n\n// @docsMissing\n/**\n * @platform android\n */\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\n// @docsMissing\n/**\n * @platform android\n */\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\n// @docsMissing\n/**\n * @platform ios\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\n// @docsMissing\nexport enum AudioQuality {\n MIN = 0,\n LOW = 0x20,\n MEDIUM = 0x40,\n HIGH = 0x60,\n MAX = 0x7f,\n}\n\n// @docsMissing\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 * @platform android\n */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n * @platform ios\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n * @platform web\n */\n web?: RecordingOptionsWeb;\n};\n\n// @docsMissing\n/**\n * @platform web\n */\nexport type RecordingOptionsWeb = {\n mimeType?: string;\n bitsPerSecond?: number;\n};\n\n// @docsMissing\n/**\n * @platform ios\n */\nexport type RecordingOptionsIos = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.\n */\n outputFormat?: string | IOSOutputFormat | number;\n /**\n * The desired audio quality. See the [`AudioQuality`](#audioquality) enum for all valid values.\n */\n audioQuality: AudioQuality | number;\n /**\n * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.\n */\n bitRateStrategy?: number;\n /**\n * The desired bit depth hint.\n *\n * @example 16\n */\n bitDepthHint?: number;\n /**\n * The desired PCM bit depth.\n *\n * @example 16\n */\n linearPCMBitDepth?: number;\n /**\n * A boolean describing if the PCM data should be formatted in big endian.\n */\n linearPCMIsBigEndian?: boolean;\n /**\n * A boolean describing if the PCM data should be encoded in floating point or integral values.\n */\n linearPCMIsFloat?: boolean;\n};\n\n// @docsMissing\n/**\n * @platform android\n */\nexport type RecordingOptionsAndroid = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.\n */\n outputFormat: AndroidOutputFormat;\n /**\n * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.\n */\n audioEncoder: AndroidAudioEncoder;\n /**\n * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still\n * be called after this point).\n *\n * @example\n * `65536`\n */\n maxFileSize?: number;\n};\n\nexport type AudioMode = {\n /**\n * Determines if audio playback is allowed when the device is in silent mode.\n *\n * @platform ios\n */\n playsInSilentMode: boolean;\n /**\n * Determines how the audio session interacts with other sessions.\n *\n * @platform ios\n */\n interruptionMode: InterruptionMode;\n /**\n * Determines how the audio session interacts with other sessions on Android.\n *\n * @platform android\n */\n interruptionModeAndroid: InterruptionModeAndroid;\n /**\n * Whether the audio session allows recording.\n *\n * @default false\n * @platform ios\n */\n allowsRecording: boolean;\n /**\n * Whether the audio session stays active when the app moves to the background.\n * @default false\n */\n shouldPlayInBackground: boolean;\n /**\n * Whether the audio should route through the earpiece.\n * @platform android\n */\n shouldRouteThroughEarpiece: boolean;\n};\n\n// @docsMissing\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n\n// @docsMissing\nexport type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';\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,EAC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AQrC,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"}
@@ -45,6 +45,9 @@ function getUserMedia(constraints) {
45
45
  throw error;
46
46
  };
47
47
  return new Promise((resolve, reject) => {
48
+ // TODO(@kitten): The types indicates that this is incorrect.
49
+ // Please check whether this is correct!
50
+ // @ts-expect-error: The `successCallback` doesn't match a `resolve` function
48
51
  getUserMedia.call(navigator, constraints, resolve, reject);
49
52
  });
50
53
  }
@@ -84,6 +87,7 @@ export class AudioPlayerWeb extends globalThis.expo.SharedObject {
84
87
  shouldCorrectPitch = false;
85
88
  src = null;
86
89
  media;
90
+ // @ts-expect-error: TODO(@kitten): Is this unintentionally unused?
87
91
  interval = 100;
88
92
  isPlaying = false;
89
93
  loaded = false;
@@ -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;AACxD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,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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AO,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;IACpD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,OAAO;YAChC,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { 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,\n currentTime: media.currentTime,\n playbackState: '',\n timeControlStatus: isPlaying ? 'playing' : 'paused',\n reasonForWaitingToPlay: '',\n playing: isPlaying,\n didJustFinish: media.ended,\n isBuffering: false,\n playbackRate: media.playbackRate,\n shouldCorrectPitch: false,\n mute: media.muted,\n loop: media.loop,\n };\n\n return status;\n}\n\nexport class AudioPlayerWeb\n extends globalThis.expo.SharedObject<AudioEvents>\n implements AudioPlayer\n{\n constructor(source: AudioSource, 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;\n }\n\n get currentTime(): number {\n return this.media.currentTime;\n }\n\n get paused(): boolean {\n return this.media.paused;\n }\n\n get isLoaded(): boolean {\n return this.loaded;\n }\n\n get playbackRate(): number {\n return this.media.playbackRate;\n }\n\n set playbackRate(value: number) {\n this.media.playbackRate = value;\n }\n\n get volume(): number {\n return this.media.volume;\n }\n\n set volume(value: number) {\n this.media.volume = value;\n }\n\n get currentStatus(): AudioStatus {\n return getStatusFromMedia(this.media, this.id);\n }\n\n play(): void {\n this.media.play();\n this.isPlaying = true;\n }\n\n pause(): void {\n this.media.pause();\n this.isPlaying = false;\n }\n\n replace(source: AudioSource): void {\n this.src = source;\n this.media = this._createMediaElement();\n }\n\n async seekTo(seconds: number): Promise<void> {\n this.media.currentTime = seconds;\n }\n\n // Not supported on web\n setAudioSamplingEnabled(enabled: boolean): void {\n this.isAudioSamplingSupported = false;\n }\n\n setPlaybackRate(second: number, pitchCorrectionQuality?: PitchCorrectionQuality): void {\n this.media.playbackRate = second;\n this.shouldCorrectPitch = pitchCorrectionQuality === 'high';\n this.media.preservesPitch = this.shouldCorrectPitch;\n }\n\n remove(): void {\n this.media.pause();\n this.media.removeAttribute('src');\n this.media.load();\n getStatusFromMedia(this.media, this.id);\n }\n\n _createMediaElement(): 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"]}
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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f,CAAC;IACJ,CAAC;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 // TODO(@kitten): The types indicates that this is incorrect.\n // Please check whether this is correct!\n // @ts-expect-error: The `successCallback` doesn't match a `resolve` function\n getUserMedia.call(navigator, constraints, resolve, reject);\n });\n}\n\nfunction getStatusFromMedia(media: HTMLMediaElement, id: number): AudioStatus {\n const isPlaying = !!(\n media.currentTime > 0 &&\n !media.paused &&\n !media.ended &&\n media.readyState > 2\n );\n\n const status: AudioStatus = {\n id,\n isLoaded: true,\n duration: media.duration,\n currentTime: media.currentTime,\n playbackState: '',\n timeControlStatus: isPlaying ? 'playing' : 'paused',\n reasonForWaitingToPlay: '',\n playing: isPlaying,\n didJustFinish: media.ended,\n isBuffering: false,\n playbackRate: media.playbackRate,\n shouldCorrectPitch: false,\n mute: media.muted,\n loop: media.loop,\n };\n\n return status;\n}\n\nexport class AudioPlayerWeb\n extends globalThis.expo.SharedObject<AudioEvents>\n implements AudioPlayer\n{\n constructor(source: AudioSource, 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 // @ts-expect-error: TODO(@kitten): Is this unintentionally unused?\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;\n }\n\n get currentTime(): number {\n return this.media.currentTime;\n }\n\n get paused(): boolean {\n return this.media.paused;\n }\n\n get isLoaded(): boolean {\n return this.loaded;\n }\n\n get playbackRate(): number {\n return this.media.playbackRate;\n }\n\n set playbackRate(value: number) {\n this.media.playbackRate = value;\n }\n\n get volume(): number {\n return this.media.volume;\n }\n\n set volume(value: number) {\n this.media.volume = value;\n }\n\n get currentStatus(): AudioStatus {\n return getStatusFromMedia(this.media, this.id);\n }\n\n play(): void {\n this.media.play();\n this.isPlaying = true;\n }\n\n pause(): void {\n this.media.pause();\n this.isPlaying = false;\n }\n\n replace(source: AudioSource): void {\n this.src = source;\n this.media = this._createMediaElement();\n }\n\n async seekTo(seconds: number): Promise<void> {\n this.media.currentTime = seconds;\n }\n\n // Not supported on web\n setAudioSamplingEnabled(enabled: boolean): void {\n this.isAudioSamplingSupported = false;\n }\n\n setPlaybackRate(second: number, pitchCorrectionQuality?: PitchCorrectionQuality): void {\n this.media.playbackRate = second;\n this.shouldCorrectPitch = pitchCorrectionQuality === 'high';\n this.media.preservesPitch = this.shouldCorrectPitch;\n }\n\n remove(): void {\n this.media.pause();\n this.media.removeAttribute('src');\n this.media.load();\n getStatusFromMedia(this.media, this.id);\n }\n\n _createMediaElement(): 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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoAudio.d.ts","sourceRoot":"","sources":["../src/ExpoAudio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAA4B,MAAM,mBAAmB,CAAC;AAIjF,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;AAS/D,wBAAgB,cAAc,CAC5B,MAAM,GAAE,WAAkB,EAC1B,cAAc,GAAE,MAAY,GAC3B,WAAW,CAMb;AAGD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAGrE;AAGD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,QAShG;AAGD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GACjD,aAA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BAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,QAShG;AAGD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GACjD,aAAa,CAcf;AAGD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,GAAE,MAAY,iBAYpF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW,EACnD,cAAc,GAAE,MAAY,GAC3B,WAAW,CAGb;AAGD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;AAGD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAU/E;AAGD,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEpF;AAGD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEhF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -82,6 +82,7 @@ export async function setAudioModeAsync(mode) {
82
82
  : {
83
83
  shouldPlayInBackground: mode.shouldPlayInBackground,
84
84
  shouldRouteThroughEarpiece: mode.shouldRouteThroughEarpiece,
85
+ interruptionMode: mode.interruptionModeAndroid,
85
86
  };
86
87
  return await AudioModule.setAudioModeAsync(audioMode);
87
88
  }
@@ -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,E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,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';\nimport { Platform } from 'react-native';\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\n// @docsMissing\nexport function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\n// @docsMissing\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 () => subscription.remove();\n }, [player.id]);\n}\n\n// @docsMissing\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\n// @docsMissing\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.\n * > See the [Using the `AudioPlayer` directly](#using-the-audioplayer-directly) section for more details.\n * @param source\n * @param updateInterval\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\n// @docsMissing\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\n// @docsMissing\nexport async function setAudioModeAsync(mode: Partial<AudioMode>): Promise<void> {\n const audioMode: Partial<AudioMode> =\n Platform.OS === 'ios'\n ? mode\n : {\n shouldPlayInBackground: mode.shouldPlayInBackground,\n shouldRouteThroughEarpiece: mode.shouldRouteThroughEarpiece,\n };\n return await AudioModule.setAudioModeAsync(audioMode);\n}\n\n// @docsMissing\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\n// @docsMissing\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { Aud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AAW,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACxD,CAAC;AAED,eAAe;AACf,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,MAAM,WAAW,CAAC,gCAAgC,EAAE,CAAC;AAC9D,CAAC;AAED,eAAe;AACf,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';\nimport { Platform } from 'react-native';\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\n// @docsMissing\nexport function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\n// @docsMissing\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 () => subscription.remove();\n }, [player.id]);\n}\n\n// @docsMissing\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\n// @docsMissing\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.\n * > See the [Using the `AudioPlayer` directly](#using-the-audioplayer-directly) section for more details.\n * @param source\n * @param updateInterval\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\n// @docsMissing\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\n// @docsMissing\nexport async function setAudioModeAsync(mode: Partial<AudioMode>): Promise<void> {\n const audioMode: Partial<AudioMode> =\n Platform.OS === 'ios'\n ? mode\n : {\n shouldPlayInBackground: mode.shouldPlayInBackground,\n shouldRouteThroughEarpiece: mode.shouldRouteThroughEarpiece,\n interruptionMode: mode.interruptionModeAndroid,\n };\n return await AudioModule.setAudioModeAsync(audioMode);\n}\n\n// @docsMissing\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\n// @docsMissing\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
@@ -8,7 +8,7 @@
8
8
  "publication": {
9
9
  "groupId": "expo.modules.audio",
10
10
  "artifactId": "expo.modules.audio",
11
- "version": "0.4.1",
11
+ "version": "0.4.3",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -0,0 +1 @@
1
+ d9806afca725f0656507326bc8b0d7db75e75ccd2ce4e1ea626209cef8909756
@@ -0,0 +1 @@
1
+ 62186f8682284e739c2bad57001ab13df39e5aeaf2ba3de1414ab6022706b6a2aa27d885e0e3461ec8d9046432a99f7768aaf543254a813e64857e20afb8f92d
@@ -0,0 +1 @@
1
+ afba18ce78ec8af3fd7e1f057c7af8de0409ec37
@@ -0,0 +1 @@
1
+ b454e054c8b967eba2af8fa695eb3e288a5ab03855945a5b904267a81e814e91
@@ -0,0 +1 @@
1
+ a0b3065f75bfe4f2b39cb9ebd0d8c1852643f94409f94560c2b33f033fc3d4f07da0406bbe2a277ac6f110fe7e2de292d07695487513234a82ad102e015802e9
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "expo.modules.audio",
5
5
  "module": "expo.modules.audio",
6
- "version": "0.4.1",
6
+ "version": "0.4.3",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.audio-0.4.1.aar",
28
- "url": "expo.modules.audio-0.4.1.aar",
29
- "size": 179393,
30
- "sha512": "7510b8f05865d812eb2294ffb9f9059e5237fc5f328bed1657c4481b5fda1d91e52bdcf3581a6a0ceb5ec3b3b462ca0b81b79d41c9c3973c7cdb040c20a7dbd2",
31
- "sha256": "e897766f3c444bc2c74fa302d4530d0a8f58c21601ac35aa6184ba47a24d218f",
32
- "sha1": "719e75a52132d06461128b0c0a1e3302afb09283",
33
- "md5": "8dccebc6f2514af0870fed9b6c244f2c"
27
+ "name": "expo.modules.audio-0.4.3.aar",
28
+ "url": "expo.modules.audio-0.4.3.aar",
29
+ "size": 184916,
30
+ "sha512": "a0b3065f75bfe4f2b39cb9ebd0d8c1852643f94409f94560c2b33f033fc3d4f07da0406bbe2a277ac6f110fe7e2de292d07695487513234a82ad102e015802e9",
31
+ "sha256": "b454e054c8b967eba2af8fa695eb3e288a5ab03855945a5b904267a81e814e91",
32
+ "sha1": "afba18ce78ec8af3fd7e1f057c7af8de0409ec37",
33
+ "md5": "f9e65a4d3c93f2b651a29f6d1c9a25e1"
34
34
  }
35
35
  ]
36
36
  },
@@ -95,13 +95,13 @@
95
95
  ],
96
96
  "files": [
97
97
  {
98
- "name": "expo.modules.audio-0.4.1.aar",
99
- "url": "expo.modules.audio-0.4.1.aar",
100
- "size": 179393,
101
- "sha512": "7510b8f05865d812eb2294ffb9f9059e5237fc5f328bed1657c4481b5fda1d91e52bdcf3581a6a0ceb5ec3b3b462ca0b81b79d41c9c3973c7cdb040c20a7dbd2",
102
- "sha256": "e897766f3c444bc2c74fa302d4530d0a8f58c21601ac35aa6184ba47a24d218f",
103
- "sha1": "719e75a52132d06461128b0c0a1e3302afb09283",
104
- "md5": "8dccebc6f2514af0870fed9b6c244f2c"
98
+ "name": "expo.modules.audio-0.4.3.aar",
99
+ "url": "expo.modules.audio-0.4.3.aar",
100
+ "size": 184916,
101
+ "sha512": "a0b3065f75bfe4f2b39cb9ebd0d8c1852643f94409f94560c2b33f033fc3d4f07da0406bbe2a277ac6f110fe7e2de292d07695487513234a82ad102e015802e9",
102
+ "sha256": "b454e054c8b967eba2af8fa695eb3e288a5ab03855945a5b904267a81e814e91",
103
+ "sha1": "afba18ce78ec8af3fd7e1f057c7af8de0409ec37",
104
+ "md5": "f9e65a4d3c93f2b651a29f6d1c9a25e1"
105
105
  }
106
106
  ]
107
107
  },
@@ -115,13 +115,13 @@
115
115
  },
116
116
  "files": [
117
117
  {
118
- "name": "expo.modules.audio-0.4.1-sources.jar",
119
- "url": "expo.modules.audio-0.4.1-sources.jar",
120
- "size": 11134,
121
- "sha512": "98b3cac6143e10338c8b38d9876560c93731080fea38c016eca1ffe67e72c7acde098fae38bf6ee8b232d8fe7306d4b9b5caf3ebd8a0f049928a2cbf3a95646e",
122
- "sha256": "5a6a220721149b8a4e081a68d683b2d36781660d4d195a3b2690241d7e8d1328",
123
- "sha1": "9325d605d24414168d7471b95c052c041ba0367a",
124
- "md5": "f4b0fe741ee04dfcf2b58a41d050dd7e"
118
+ "name": "expo.modules.audio-0.4.3-sources.jar",
119
+ "url": "expo.modules.audio-0.4.3-sources.jar",
120
+ "size": 11770,
121
+ "sha512": "62186f8682284e739c2bad57001ab13df39e5aeaf2ba3de1414ab6022706b6a2aa27d885e0e3461ec8d9046432a99f7768aaf543254a813e64857e20afb8f92d",
122
+ "sha256": "d9806afca725f0656507326bc8b0d7db75e75ccd2ce4e1ea626209cef8909756",
123
+ "sha1": "f759ea485190b58c8e59734d263dccab32dd7110",
124
+ "md5": "2fb5759d28c945fe08c1530cb736aaf4"
125
125
  }
126
126
  ]
127
127
  }
@@ -0,0 +1 @@
1
+ 7e96140599698315b7871d1a9d7ffa36db4a5c039ae78fba9e766f6c893cf9f2
@@ -0,0 +1 @@
1
+ 16bdf0ad39b2ec109f3a9473cab87c62c508cd5d42a589ee969b3765a332db7b2725140934fbdc049a19622827990205562dd1a6a1a94fca634284ae2800a620
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>expo.modules.audio</groupId>
11
11
  <artifactId>expo.modules.audio</artifactId>
12
- <version>0.4.1</version>
12
+ <version>0.4.3</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.audio</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 9c40efe180098d84d1076448477734edb38bc121
@@ -0,0 +1 @@
1
+ 40d749480c964891fb5882e713b3d9ecc3b4a70d792db851f7e7dcf7d8da36ef
@@ -0,0 +1 @@
1
+ 23b78972a57e8ade02a913b8402f92ca714c123757706424d4d7937cd02f0ded71b0de96fc158c9d214b77011110c07bfbead6644a448d4fe94f264d0ed2f94a
@@ -3,11 +3,11 @@
3
3
  <groupId>expo.modules.audio</groupId>
4
4
  <artifactId>expo.modules.audio</artifactId>
5
5
  <versioning>
6
- <latest>0.4.1</latest>
7
- <release>0.4.1</release>
6
+ <latest>0.4.3</latest>
7
+ <release>0.4.3</release>
8
8
  <versions>
9
- <version>0.4.1</version>
9
+ <version>0.4.3</version>
10
10
  </versions>
11
- <lastUpdated>20250409202825</lastUpdated>
11
+ <lastUpdated>20250425210752</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 825f79dd7ed68e05230a07b1dbd6bfe1
1
+ ad235da22d1c7a2d0de25929ba70d049
@@ -1 +1 @@
1
- af70ed50d0f32529e5037fd0d1f72d8a0f1ddbdb
1
+ af22b3f0329d0a4d32d9fb1422521ca200d7e2cc
@@ -1 +1 @@
1
- 134984f756d97d930857cbf185614400c924096dc6d7cf402a8336e71dba1b07
1
+ 8a5fb565d1d99570622e07f9a605b263028a558b0796b2caa8b871181559d1d4
@@ -1 +1 @@
1
- 1a41b01f5f4b569fbe3a0fa817cd291b34d123e43b37190f9f531278cbd369241b37b1f698d8da5c952dc4b2dfb342fafa0e32e654f41da2019b42fd6e7a56f9
1
+ b7142ea73f4e163439713fbad38943277acabcd5cc85b50a79bca49a14a019a521aca15099044924a57da307116d8898e6ec3b1cd19e764e542f0d15225f2267
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-audio",
3
3
  "title": "Expo Audio",
4
- "version": "0.4.1",
4
+ "version": "0.4.3",
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",
@@ -33,12 +33,12 @@
33
33
  "license": "MIT",
34
34
  "dependencies": {},
35
35
  "devDependencies": {
36
- "expo-module-scripts": "^4.1.1"
36
+ "expo-module-scripts": "^4.1.5"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "expo": "*",
40
40
  "react": "*",
41
41
  "react-native": "*"
42
42
  },
43
- "gitHead": "1914bb35d23af23078da37e70988261844436505"
43
+ "gitHead": "3cd208465df78e385ca9380531bbbfe33ca68e81"
44
44
  }
@@ -294,6 +294,12 @@ export type AudioMode = {
294
294
  * @platform ios
295
295
  */
296
296
  interruptionMode: InterruptionMode;
297
+ /**
298
+ * Determines how the audio session interacts with other sessions on Android.
299
+ *
300
+ * @platform android
301
+ */
302
+ interruptionModeAndroid: InterruptionModeAndroid;
297
303
  /**
298
304
  * Whether the audio session allows recording.
299
305
  *
@@ -315,3 +321,6 @@ export type AudioMode = {
315
321
 
316
322
  // @docsMissing
317
323
  export type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';
324
+
325
+ // @docsMissing
326
+ export type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';
@@ -63,6 +63,9 @@ function getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>
63
63
  };
64
64
 
65
65
  return new Promise((resolve, reject) => {
66
+ // TODO(@kitten): The types indicates that this is incorrect.
67
+ // Please check whether this is correct!
68
+ // @ts-expect-error: The `successCallback` doesn't match a `resolve` function
66
69
  getUserMedia.call(navigator, constraints, resolve, reject);
67
70
  });
68
71
  }
@@ -113,6 +116,7 @@ export class AudioPlayerWeb
113
116
 
114
117
  private src: AudioSource = null;
115
118
  private media: HTMLAudioElement;
119
+ // @ts-expect-error: TODO(@kitten): Is this unintentionally unused?
116
120
  private interval = 100;
117
121
  private isPlaying = false;
118
122
  private loaded = false;
package/src/ExpoAudio.ts CHANGED
@@ -120,6 +120,7 @@ export async function setAudioModeAsync(mode: Partial<AudioMode>): Promise<void>
120
120
  : {
121
121
  shouldPlayInBackground: mode.shouldPlayInBackground,
122
122
  shouldRouteThroughEarpiece: mode.shouldRouteThroughEarpiece,
123
+ interruptionMode: mode.interruptionModeAndroid,
123
124
  };
124
125
  return await AudioModule.setAudioModeAsync(audioMode);
125
126
  }
@@ -0,0 +1 @@
1
+ /// <reference path="../../../expo-asset/src/ts-declarations/react-native-assets.d.ts" />
@@ -1 +0,0 @@
1
- 5a6a220721149b8a4e081a68d683b2d36781660d4d195a3b2690241d7e8d1328
@@ -1 +0,0 @@
1
- 98b3cac6143e10338c8b38d9876560c93731080fea38c016eca1ffe67e72c7acde098fae38bf6ee8b232d8fe7306d4b9b5caf3ebd8a0f049928a2cbf3a95646e
@@ -1 +0,0 @@
1
- 719e75a52132d06461128b0c0a1e3302afb09283
@@ -1 +0,0 @@
1
- e897766f3c444bc2c74fa302d4530d0a8f58c21601ac35aa6184ba47a24d218f
@@ -1 +0,0 @@
1
- 7510b8f05865d812eb2294ffb9f9059e5237fc5f328bed1657c4481b5fda1d91e52bdcf3581a6a0ceb5ec3b3b462ca0b81b79d41c9c3973c7cdb040c20a7dbd2
@@ -1 +0,0 @@
1
- a4a8a9c402ef271249425767ba89b81760a6d313
@@ -1 +0,0 @@
1
- 374cd7543c086437f227e34d1f5ca121a5a6e1288393349eddef4631d5203091
@@ -1 +0,0 @@
1
- 3afe5439806ba1000780c2e21089a79b76c22afec6090d32493a0b0e1d4fd3b45dbf9af92c8a2e91193dc7ecb98f7649cd94c635b722d4aa23a5a48fd7321d3f
@@ -1 +0,0 @@
1
- 77ec52f87675a519715cea8f45340925b3b8637f
@@ -1 +0,0 @@
1
- 1ac794a240307036df5c1326cb8b28156e17912699f86bda4009ab8aff1c625a
@@ -1 +0,0 @@
1
- 2187554d821279acd760e8256cce828b72a3018b91249de640a423cc8925b1fbd94781c24bc850e2fdfe84cebf62f47834002dc16ec64dae8053b3093dbffc91