expo-audio 0.4.3 → 0.4.5

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 (31) 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 +36 -24
  4. package/android/src/main/java/expo/modules/audio/AudioRecorder.kt +7 -3
  5. package/expo-module.config.json +1 -7
  6. package/package.json +3 -3
  7. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar +0 -0
  8. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.md5 +0 -1
  9. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.sha1 +0 -1
  10. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.sha256 +0 -1
  11. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3-sources.jar.sha512 +0 -1
  12. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar +0 -0
  13. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.md5 +0 -1
  14. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.sha1 +0 -1
  15. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.sha256 +0 -1
  16. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.aar.sha512 +0 -1
  17. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module +0 -129
  18. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.md5 +0 -1
  19. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.sha1 +0 -1
  20. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.sha256 +0 -1
  21. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.module.sha512 +0 -1
  22. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom +0 -71
  23. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.md5 +0 -1
  24. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.sha1 +0 -1
  25. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.sha256 +0 -1
  26. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.3/expo.modules.audio-0.4.3.pom.sha512 +0 -1
  27. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml +0 -13
  28. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.md5 +0 -1
  29. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha1 +0 -1
  30. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha256 +0 -1
  31. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.4.5 — 2025-05-08
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [Android] Correctly handle recording URL's and local assets in production. ([#36737](https://github.com/expo/expo/pull/36737) by [@alanjhughes](https://github.com/alanjhughes))
18
+
19
+ ## 0.4.4 — 2025-04-30
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 0.4.3 — 2025-04-25
14
24
 
15
25
  ### 💡 Others
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'expo.modules.audio'
7
- version = '0.4.3'
7
+ version = '0.4.5'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.audio"
11
11
  defaultConfig {
12
12
  versionCode 1
13
- versionName "0.4.3"
13
+ versionName "0.4.5"
14
14
  }
15
15
 
16
16
  compileOptions {
@@ -1,6 +1,7 @@
1
1
  package expo.modules.audio
2
2
 
3
3
  import android.Manifest
4
+ import android.content.ContentResolver
4
5
  import android.content.Context
5
6
  import android.content.pm.PackageManager
6
7
  import android.media.AudioAttributes
@@ -10,6 +11,7 @@ import android.net.Uri
10
11
  import android.os.Build
11
12
  import android.util.Log
12
13
  import androidx.core.content.ContextCompat
14
+ import androidx.core.net.toUri
13
15
  import androidx.media3.common.C.CONTENT_TYPE_DASH
14
16
  import androidx.media3.common.C.CONTENT_TYPE_HLS
15
17
  import androidx.media3.common.C.CONTENT_TYPE_OTHER
@@ -37,7 +39,6 @@ import kotlinx.coroutines.runBlocking
37
39
  import okhttp3.OkHttpClient
38
40
  import java.io.File
39
41
  import kotlin.math.min
40
- import androidx.core.net.toUri
41
42
 
42
43
  @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
43
44
  class AudioModule : Module() {
@@ -401,7 +402,9 @@ class AudioModule : Module() {
401
402
  }
402
403
 
403
404
  Property("uri") { ref ->
404
- ref.filePath
405
+ ref.filePath?.let {
406
+ Uri.fromFile(File(it)).toString()
407
+ } ?: ""
405
408
  }
406
409
 
407
410
  Property("isRecording") { ref ->
@@ -456,35 +459,44 @@ class AudioModule : Module() {
456
459
  }
457
460
  }
458
461
 
459
- private fun createMediaItem(source: AudioSource?): MediaSource? = source?.uri?.let { uri ->
460
- val factory = createDataSourceFactory(source)
461
- val sourceUri = if (Util.isLocalFileUri(uri.toUri())) {
462
- Uri.fromFile(File(source.uri))
463
- } else {
464
- source.uri.toUri()
462
+ private fun createMediaItem(source: AudioSource?): MediaSource? = source?.uri?.let { uriString ->
463
+ val uri = uriString.toUri()
464
+ val mediaItem = when (uri.scheme) {
465
+ null -> MediaItem.fromUri(getRawResourceURI(uriString))
466
+ else -> MediaItem.fromUri(uri)
465
467
  }
466
- val item = MediaItem.fromUri(sourceUri)
467
- buildMediaSourceFactory(factory, item)
468
- }
469
468
 
470
- private fun createDataSourceFactory(audioSource: AudioSource): DataSource.Factory {
471
- val uri = if (Util.isLocalFileUri(Uri.parse(audioSource.uri))) {
472
- Uri.fromFile(File(audioSource.uri))
473
- } else {
474
- Uri.parse(audioSource.uri)
469
+ val factory = when (uri.scheme) {
470
+ "http", "https" -> httpDataSourceFactory(source.headers)
471
+ else -> DefaultDataSource.Factory(context)
475
472
  }
476
- val isLocal = Util.isLocalFileUri(uri)
477
- return if (isLocal) {
478
- DefaultDataSource.Factory(context)
479
- } else {
480
- OkHttpDataSource.Factory(httpClient).apply {
481
- audioSource.headers?.let { headers ->
482
- setDefaultRequestProperties(headers)
483
- }
473
+ return buildMediaSourceFactory(factory, mediaItem)
474
+ }
475
+
476
+ private fun httpDataSourceFactory(headers: Map<String, String>?): DataSource.Factory {
477
+ return OkHttpDataSource.Factory(httpClient).apply {
478
+ headers?.let { headers ->
479
+ setDefaultRequestProperties(headers)
484
480
  }
485
481
  }
486
482
  }
487
483
 
484
+ private fun getRawResourceURI(file: String): Uri {
485
+ val resId = context.resources.getIdentifier(file, "raw", context.packageName)
486
+
487
+ return when {
488
+ resId == 0 ->
489
+ Uri.fromFile(File(file))
490
+ else ->
491
+ Uri.Builder()
492
+ .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
493
+ .authority(context.packageName)
494
+ .appendPath("raw")
495
+ .appendPath(file)
496
+ .build()
497
+ }
498
+ }
499
+
488
500
  private fun updatePlaySoundThroughEarpiece(playThroughEarpiece: Boolean) {
489
501
  audioManager.mode = if (playThroughEarpiece) AudioManager.MODE_IN_COMMUNICATION else AudioManager.MODE_NORMAL
490
502
  audioManager.setSpeakerphoneOn(!playThroughEarpiece)
@@ -142,9 +142,10 @@ class AudioRecorder(
142
142
 
143
143
  val filename = "recording-${UUID.randomUUID()}${options.extension}"
144
144
  try {
145
- val directory = File(context.cacheDir.toString() + File.separator + "Audio")
145
+ val directory = File(context.cacheDir, "Audio")
146
146
  ensureDirExists(directory)
147
- filePath = "$directory${File.separator}$filename"
147
+ val file = File(directory, filename)
148
+ filePath = file.absolutePath
148
149
  } catch (e: IOException) {
149
150
  // This only occurs in the case that the scoped path is not in this experience's scope,
150
151
  // which is never true.
@@ -169,7 +170,10 @@ class AudioRecorder(
169
170
  getAudioRecorderLevels()?.let {
170
171
  putInt("metering", it)
171
172
  }
172
- putString("url", filePath)
173
+ filePath?.let {
174
+ val path = Uri.fromFile(File(it)).toString()
175
+ putString("url", path)
176
+ }
173
177
  }
174
178
  } else {
175
179
  Bundle().apply {
@@ -4,12 +4,6 @@
4
4
  "modules": ["AudioModule"]
5
5
  },
6
6
  "android": {
7
- "modules": ["expo.modules.audio.AudioModule"],
8
- "publication": {
9
- "groupId": "expo.modules.audio",
10
- "artifactId": "expo.modules.audio",
11
- "version": "0.4.3",
12
- "repository": "local-maven-repo"
13
- }
7
+ "modules": ["expo.modules.audio.AudioModule"]
14
8
  }
15
9
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-audio",
3
3
  "title": "Expo Audio",
4
- "version": "0.4.3",
4
+ "version": "0.4.5",
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.5"
36
+ "expo-module-scripts": "^4.1.7"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "expo": "*",
40
40
  "react": "*",
41
41
  "react-native": "*"
42
42
  },
43
- "gitHead": "3cd208465df78e385ca9380531bbbfe33ca68e81"
43
+ "gitHead": "49c9d53cf0a9fc8179d1c8f5268beadd141f70ca"
44
44
  }
@@ -1 +0,0 @@
1
- d9806afca725f0656507326bc8b0d7db75e75ccd2ce4e1ea626209cef8909756
@@ -1 +0,0 @@
1
- 62186f8682284e739c2bad57001ab13df39e5aeaf2ba3de1414ab6022706b6a2aa27d885e0e3461ec8d9046432a99f7768aaf543254a813e64857e20afb8f92d
@@ -1 +0,0 @@
1
- afba18ce78ec8af3fd7e1f057c7af8de0409ec37
@@ -1 +0,0 @@
1
- b454e054c8b967eba2af8fa695eb3e288a5ab03855945a5b904267a81e814e91
@@ -1 +0,0 @@
1
- a0b3065f75bfe4f2b39cb9ebd0d8c1852643f94409f94560c2b33f033fc3d4f07da0406bbe2a277ac6f110fe7e2de292d07695487513234a82ad102e015802e9
@@ -1,129 +0,0 @@
1
- {
2
- "formatVersion": "1.1",
3
- "component": {
4
- "group": "expo.modules.audio",
5
- "module": "expo.modules.audio",
6
- "version": "0.4.3",
7
- "attributes": {
8
- "org.gradle.status": "release"
9
- }
10
- },
11
- "createdBy": {
12
- "gradle": {
13
- "version": "8.13"
14
- }
15
- },
16
- "variants": [
17
- {
18
- "name": "releaseVariantReleaseApiPublication",
19
- "attributes": {
20
- "org.gradle.category": "library",
21
- "org.gradle.dependency.bundling": "external",
22
- "org.gradle.libraryelements": "aar",
23
- "org.gradle.usage": "java-api"
24
- },
25
- "files": [
26
- {
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
- }
35
- ]
36
- },
37
- {
38
- "name": "releaseVariantReleaseRuntimePublication",
39
- "attributes": {
40
- "org.gradle.category": "library",
41
- "org.gradle.dependency.bundling": "external",
42
- "org.gradle.libraryelements": "aar",
43
- "org.gradle.usage": "java-runtime"
44
- },
45
- "dependencies": [
46
- {
47
- "group": "org.jetbrains.kotlin",
48
- "module": "kotlin-stdlib-jdk7",
49
- "version": {
50
- "requires": "2.0.21"
51
- }
52
- },
53
- {
54
- "group": "androidx.appcompat",
55
- "module": "appcompat",
56
- "version": {
57
- "requires": "1.7.0"
58
- }
59
- },
60
- {
61
- "group": "androidx.media3",
62
- "module": "media3-exoplayer",
63
- "version": {
64
- "requires": "1.4.0"
65
- }
66
- },
67
- {
68
- "group": "androidx.media3",
69
- "module": "media3-exoplayer-dash",
70
- "version": {
71
- "requires": "1.4.0"
72
- }
73
- },
74
- {
75
- "group": "androidx.media3",
76
- "module": "media3-datasource-okhttp",
77
- "version": {
78
- "requires": "1.4.0"
79
- }
80
- },
81
- {
82
- "group": "androidx.media3",
83
- "module": "media3-exoplayer-hls",
84
- "version": {
85
- "requires": "1.4.0"
86
- }
87
- },
88
- {
89
- "group": "androidx.media3",
90
- "module": "media3-exoplayer-smoothstreaming",
91
- "version": {
92
- "requires": "1.4.0"
93
- }
94
- }
95
- ],
96
- "files": [
97
- {
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
- }
106
- ]
107
- },
108
- {
109
- "name": "releaseVariantReleaseSourcePublication",
110
- "attributes": {
111
- "org.gradle.category": "documentation",
112
- "org.gradle.dependency.bundling": "external",
113
- "org.gradle.docstype": "sources",
114
- "org.gradle.usage": "java-runtime"
115
- },
116
- "files": [
117
- {
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
- }
126
- ]
127
- }
128
- ]
129
- }
@@ -1 +0,0 @@
1
- b70f8cbcf6fe581020ab5269a266a92590d28eba
@@ -1 +0,0 @@
1
- 7e96140599698315b7871d1a9d7ffa36db4a5c039ae78fba9e766f6c893cf9f2
@@ -1 +0,0 @@
1
- 16bdf0ad39b2ec109f3a9473cab87c62c508cd5d42a589ee969b3765a332db7b2725140934fbdc049a19622827990205562dd1a6a1a94fca634284ae2800a620
@@ -1,71 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
- <!-- This module was also published with a richer model, Gradle metadata, -->
5
- <!-- which should be used instead. Do not delete the following line which -->
6
- <!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
7
- <!-- that they should prefer consuming it instead. -->
8
- <!-- do_not_remove: published-with-gradle-metadata -->
9
- <modelVersion>4.0.0</modelVersion>
10
- <groupId>expo.modules.audio</groupId>
11
- <artifactId>expo.modules.audio</artifactId>
12
- <version>0.4.3</version>
13
- <packaging>aar</packaging>
14
- <name>expo.modules.audio</name>
15
- <url>https://github.com/expo/expo</url>
16
- <licenses>
17
- <license>
18
- <name>MIT License</name>
19
- <url>https://github.com/expo/expo/blob/main/LICENSE</url>
20
- </license>
21
- </licenses>
22
- <scm>
23
- <connection>https://github.com/expo/expo.git</connection>
24
- <developerConnection>https://github.com/expo/expo.git</developerConnection>
25
- <url>https://github.com/expo/expo</url>
26
- </scm>
27
- <dependencies>
28
- <dependency>
29
- <groupId>org.jetbrains.kotlin</groupId>
30
- <artifactId>kotlin-stdlib-jdk7</artifactId>
31
- <version>2.0.21</version>
32
- <scope>runtime</scope>
33
- </dependency>
34
- <dependency>
35
- <groupId>androidx.appcompat</groupId>
36
- <artifactId>appcompat</artifactId>
37
- <version>1.7.0</version>
38
- <scope>runtime</scope>
39
- </dependency>
40
- <dependency>
41
- <groupId>androidx.media3</groupId>
42
- <artifactId>media3-exoplayer</artifactId>
43
- <version>1.4.0</version>
44
- <scope>runtime</scope>
45
- </dependency>
46
- <dependency>
47
- <groupId>androidx.media3</groupId>
48
- <artifactId>media3-exoplayer-dash</artifactId>
49
- <version>1.4.0</version>
50
- <scope>runtime</scope>
51
- </dependency>
52
- <dependency>
53
- <groupId>androidx.media3</groupId>
54
- <artifactId>media3-datasource-okhttp</artifactId>
55
- <version>1.4.0</version>
56
- <scope>runtime</scope>
57
- </dependency>
58
- <dependency>
59
- <groupId>androidx.media3</groupId>
60
- <artifactId>media3-exoplayer-hls</artifactId>
61
- <version>1.4.0</version>
62
- <scope>runtime</scope>
63
- </dependency>
64
- <dependency>
65
- <groupId>androidx.media3</groupId>
66
- <artifactId>media3-exoplayer-smoothstreaming</artifactId>
67
- <version>1.4.0</version>
68
- <scope>runtime</scope>
69
- </dependency>
70
- </dependencies>
71
- </project>
@@ -1 +0,0 @@
1
- 9c40efe180098d84d1076448477734edb38bc121
@@ -1 +0,0 @@
1
- 40d749480c964891fb5882e713b3d9ecc3b4a70d792db851f7e7dcf7d8da36ef
@@ -1 +0,0 @@
1
- 23b78972a57e8ade02a913b8402f92ca714c123757706424d4d7937cd02f0ded71b0de96fc158c9d214b77011110c07bfbead6644a448d4fe94f264d0ed2f94a
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <metadata>
3
- <groupId>expo.modules.audio</groupId>
4
- <artifactId>expo.modules.audio</artifactId>
5
- <versioning>
6
- <latest>0.4.3</latest>
7
- <release>0.4.3</release>
8
- <versions>
9
- <version>0.4.3</version>
10
- </versions>
11
- <lastUpdated>20250425210752</lastUpdated>
12
- </versioning>
13
- </metadata>
@@ -1 +0,0 @@
1
- ad235da22d1c7a2d0de25929ba70d049
@@ -1 +0,0 @@
1
- af22b3f0329d0a4d32d9fb1422521ca200d7e2cc
@@ -1 +0,0 @@
1
- 8a5fb565d1d99570622e07f9a605b263028a558b0796b2caa8b871181559d1d4
@@ -1 +0,0 @@
1
- b7142ea73f4e163439713fbad38943277acabcd5cc85b50a79bca49a14a019a521aca15099044924a57da307116d8898e6ec3b1cd19e764e542f0d15225f2267