expo-audio 0.4.5 → 0.4.6

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 +8 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/audio/AudioModule.kt +7 -3
  4. package/expo-module.config.json +7 -1
  5. package/ios/AudioUtils.swift +62 -2
  6. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6-sources.jar +0 -0
  7. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6-sources.jar.md5 +1 -0
  8. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6-sources.jar.sha1 +1 -0
  9. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6-sources.jar.sha256 +1 -0
  10. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6-sources.jar.sha512 +1 -0
  11. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.aar +0 -0
  12. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.aar.md5 +1 -0
  13. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.aar.sha1 +1 -0
  14. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.aar.sha256 +1 -0
  15. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.aar.sha512 +1 -0
  16. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.module +129 -0
  17. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.module.md5 +1 -0
  18. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.module.sha1 +1 -0
  19. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.module.sha256 +1 -0
  20. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.module.sha512 +1 -0
  21. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.pom +71 -0
  22. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.pom.md5 +1 -0
  23. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.pom.sha1 +1 -0
  24. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.pom.sha256 +1 -0
  25. package/local-maven-repo/expo/modules/audio/expo.modules.audio/0.4.6/expo.modules.audio-0.4.6.pom.sha512 +1 -0
  26. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml +13 -0
  27. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.md5 +1 -0
  28. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha1 +1 -0
  29. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha256 +1 -0
  30. package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha512 +1 -0
  31. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -10,11 +10,19 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.4.6 — 2025-06-04
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [iOS] Support base64 strings as an audio source. ([#37031](https://github.com/expo/expo/pull/37031) by [@alanjhughes](https://github.com/alanjhughes))
18
+ - [iOS] Correctly add the http headers to the `AVURLAsset`. ([#37029](https://github.com/expo/expo/pull/37029) by [@alanjhughes](https://github.com/alanjhughes))
19
+
13
20
  ## 0.4.5 — 2025-05-08
14
21
 
15
22
  ### 🐛 Bug fixes
16
23
 
17
24
  - [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))
25
+ - [Android] Run player updates on the main thread in the `audioFocusChangeListener`. ([#36957](https://github.com/expo/expo/pull/36957) by [@alanjhughes](https://github.com/alanjhughes))
18
26
 
19
27
  ## 0.4.4 — 2025-04-30
20
28
 
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'expo.modules.audio'
7
- version = '0.4.5'
7
+ version = '0.4.6'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.audio"
11
11
  defaultConfig {
12
12
  versionCode 1
13
- versionName "0.4.5"
13
+ versionName "0.4.6"
14
14
  }
15
15
 
16
16
  compileOptions {
@@ -63,7 +63,9 @@ class AudioModule : Module() {
63
63
  AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
64
64
  focusAcquired = false
65
65
  players.values.forEach {
66
- it.player.pause()
66
+ runOnMain {
67
+ it.player.pause()
68
+ }
67
69
  }
68
70
  }
69
71
 
@@ -71,7 +73,9 @@ class AudioModule : Module() {
71
73
  focusAcquired = false
72
74
  if (interruptionMode == InterruptionMode.DUCK_OTHERS) {
73
75
  players.values.forEach {
74
- it.player.volume /= 2f
76
+ runOnMain {
77
+ it.player.volume /= 2f
78
+ }
75
79
  }
76
80
  }
77
81
  }
@@ -147,7 +151,7 @@ class AudioModule : Module() {
147
151
  AsyncFunction("setIsAudioActiveAsync") { enabled: Boolean ->
148
152
  audioEnabled = enabled
149
153
  if (!enabled) {
150
- appContext.mainQueue.launch {
154
+ runOnMain {
151
155
  players.values.forEach {
152
156
  if (it.player.isPlaying) {
153
157
  it.player.pause()
@@ -4,6 +4,12 @@
4
4
  "modules": ["AudioModule"]
5
5
  },
6
6
  "android": {
7
- "modules": ["expo.modules.audio.AudioModule"]
7
+ "modules": ["expo.modules.audio.AudioModule"],
8
+ "publication": {
9
+ "groupId": "expo.modules.audio",
10
+ "artifactId": "expo.modules.audio",
11
+ "version": "0.4.6",
12
+ "repository": "local-maven-repo"
13
+ }
8
14
  }
9
15
  }
@@ -85,7 +85,18 @@ struct AudioUtils {
85
85
 
86
86
  static func createAVPlayer(from source: AudioSource?) -> AVPlayer {
87
87
  if let source, let url = source.uri {
88
- let asset = AVURLAsset(url: url, options: source.headers)
88
+ let finalUrl = if url.isBase64Audio {
89
+ handleBase64Asset(base64String: url.absoluteString) ?? url
90
+ } else {
91
+ url
92
+ }
93
+
94
+ var options: [String: Any]?
95
+ if let headers = source.headers {
96
+ options = ["AVURLAssetHTTPHeaderFieldsKey": headers]
97
+ }
98
+
99
+ let asset = AVURLAsset(url: finalUrl, options: options)
89
100
  let item = AVPlayerItem(asset: asset)
90
101
  return AVPlayer(playerItem: item)
91
102
  }
@@ -96,7 +107,18 @@ struct AudioUtils {
96
107
  guard let source, let url = source.uri else {
97
108
  return nil
98
109
  }
99
- let asset = AVURLAsset(url: url, options: source.headers)
110
+ let finalUrl = if url.isBase64Audio {
111
+ handleBase64Asset(base64String: url.absoluteString) ?? url
112
+ } else {
113
+ url
114
+ }
115
+
116
+ var options: [String: Any]?
117
+ if let headers = source.headers {
118
+ options = ["AVURLAssetHTTPHeaderFieldsKey": headers]
119
+ }
120
+
121
+ let asset = AVURLAsset(url: finalUrl, options: options)
100
122
  return AVPlayerItem(asset: asset)
101
123
  }
102
124
 
@@ -133,6 +155,38 @@ struct AudioUtils {
133
155
  return settings
134
156
  }
135
157
 
158
+ private static func handleBase64Asset(base64String: String) -> URL? {
159
+ let components = base64String.components(separatedBy: ",")
160
+ guard components.count == 2 else {
161
+ return nil
162
+ }
163
+ let mimeType = components[0].components(separatedBy: ";")[0].components(separatedBy: ":")[1]
164
+ let base64Data = components[1]
165
+
166
+ guard let data = Data(base64Encoded: base64Data, options: .ignoreUnknownCharacters) else {
167
+ return nil
168
+ }
169
+
170
+ let fileExtension = getFileExtension(for: mimeType)
171
+ let tempDirectory = FileManager.default.temporaryDirectory
172
+ let fileName = UUID().uuidString + "." + fileExtension
173
+ let fileURL = tempDirectory.appendingPathComponent(fileName)
174
+
175
+ do {
176
+ try data.write(to: fileURL)
177
+ return fileURL
178
+ } catch {
179
+ return nil
180
+ }
181
+ }
182
+
183
+ static func getFileExtension(for mimeType: String) -> String {
184
+ if let utType = UTType(mimeType: mimeType) {
185
+ return utType.preferredFilenameExtension ?? "dat"
186
+ }
187
+ return "dat"
188
+ }
189
+
136
190
  private static func createRecordingUrl(from dir: URL, with options: RecordingOptions) -> URL {
137
191
  let directoryPath = dir.appendingPathComponent("ExpoAudio")
138
192
  FileSystemUtilities.ensureDirExists(at: directoryPath)
@@ -160,3 +214,9 @@ struct AudioUtils {
160
214
  }
161
215
  }
162
216
  }
217
+
218
+ private extension URL {
219
+ var isBase64Audio: Bool {
220
+ return absoluteString.hasPrefix("data:audio/")
221
+ }
222
+ }
@@ -0,0 +1 @@
1
+ 5b83253199eda38e1c38648763d0a597739ea6b68cc8d820f0adfc58005d7d11
@@ -0,0 +1 @@
1
+ 653271097295e8ddcbec1387083547f51a4e602bc937a680506f2757179369078a817c64d8a5eee6827995487c77f722d11c87dff1afaf87a9a655755e8fcf86
@@ -0,0 +1 @@
1
+ 5789c77be1c3f39079dd124df9c6b5a6ea4c9f4e
@@ -0,0 +1 @@
1
+ ccffe7bc9275fb16f87f5ccd7f3e8a7c0d645c051cd8dcf7f93e541f1da6c90d
@@ -0,0 +1 @@
1
+ 4822e292172989e76129ff372ba1fea73fe20d90c659ee81adaf5e1a5d79841e7634f8482d86e5c52f4bf3b821161de8c6b5882306e4df05e8644488633e5c32
@@ -0,0 +1,129 @@
1
+ {
2
+ "formatVersion": "1.1",
3
+ "component": {
4
+ "group": "expo.modules.audio",
5
+ "module": "expo.modules.audio",
6
+ "version": "0.4.6",
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.6.aar",
28
+ "url": "expo.modules.audio-0.4.6.aar",
29
+ "size": 185860,
30
+ "sha512": "4822e292172989e76129ff372ba1fea73fe20d90c659ee81adaf5e1a5d79841e7634f8482d86e5c52f4bf3b821161de8c6b5882306e4df05e8644488633e5c32",
31
+ "sha256": "ccffe7bc9275fb16f87f5ccd7f3e8a7c0d645c051cd8dcf7f93e541f1da6c90d",
32
+ "sha1": "5789c77be1c3f39079dd124df9c6b5a6ea4c9f4e",
33
+ "md5": "2f81113a82d032d22895e4cc1113653e"
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.6.aar",
99
+ "url": "expo.modules.audio-0.4.6.aar",
100
+ "size": 185860,
101
+ "sha512": "4822e292172989e76129ff372ba1fea73fe20d90c659ee81adaf5e1a5d79841e7634f8482d86e5c52f4bf3b821161de8c6b5882306e4df05e8644488633e5c32",
102
+ "sha256": "ccffe7bc9275fb16f87f5ccd7f3e8a7c0d645c051cd8dcf7f93e541f1da6c90d",
103
+ "sha1": "5789c77be1c3f39079dd124df9c6b5a6ea4c9f4e",
104
+ "md5": "2f81113a82d032d22895e4cc1113653e"
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.6-sources.jar",
119
+ "url": "expo.modules.audio-0.4.6-sources.jar",
120
+ "size": 11949,
121
+ "sha512": "653271097295e8ddcbec1387083547f51a4e602bc937a680506f2757179369078a817c64d8a5eee6827995487c77f722d11c87dff1afaf87a9a655755e8fcf86",
122
+ "sha256": "5b83253199eda38e1c38648763d0a597739ea6b68cc8d820f0adfc58005d7d11",
123
+ "sha1": "2926300234a91dc3a7079b6e01968c49fd4e8be9",
124
+ "md5": "16b12ce1f64a92648c621d933188ef6b"
125
+ }
126
+ ]
127
+ }
128
+ ]
129
+ }
@@ -0,0 +1 @@
1
+ 71d01e107d8760fed3509b4e3a069efbc6352a782cf0ead8a0abf3ff409b8a44
@@ -0,0 +1 @@
1
+ b9bbc0248d57b3c94cab7a852c1bdb4ef6cf9f876138e6801e3f42f21035981fc0d1ae594dad3e9b58b1972f8679f106818632cfda20842d35886fd2e48528d8
@@ -0,0 +1,71 @@
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.6</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>
@@ -0,0 +1 @@
1
+ f77ccbbe01ae9c8e5c5dbce5bdf98e278213d507
@@ -0,0 +1 @@
1
+ dc0a0dd06bc0729b1f9d9447f1af8fb1e11407c4c8ad1142a51d23597c90e34e
@@ -0,0 +1 @@
1
+ 1e9f0635a1eada19b39a6709ad1e4f7d596164fa14a2bb08ab6692dec92ef4f95d93953c7dbf276ed570b1436907f2fd1f2e2bb63af5989edf1d6a3da2e4df9c
@@ -0,0 +1,13 @@
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.6</latest>
7
+ <release>0.4.6</release>
8
+ <versions>
9
+ <version>0.4.6</version>
10
+ </versions>
11
+ <lastUpdated>20250604230416</lastUpdated>
12
+ </versioning>
13
+ </metadata>
@@ -0,0 +1 @@
1
+ 5e38b847a67dfcd99daa36620a7e6bd8
@@ -0,0 +1 @@
1
+ 2cf3df2657ee8884b5aec968f5b95702a5892aa9
@@ -0,0 +1 @@
1
+ bbfb4512ca242ccbd6c5514a5c743c3f51ef1b659c1142f2456d39f82c07f938
@@ -0,0 +1 @@
1
+ 72e5ed48410a3e9b6154846f3d5428f94b9da3ea28894f5200e2990d104f9d12f449826139bbf4d83f3ebe644234f597a4d80c92b4b5f00494138850e29590f3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-audio",
3
3
  "title": "Expo Audio",
4
- "version": "0.4.5",
4
+ "version": "0.4.6",
5
5
  "description": "A cross-platform audio library for React Native and Expo apps.",
6
6
  "main": "build/index.js",
7
7
  "types": "build/index.d.ts",
@@ -40,5 +40,5 @@
40
40
  "react": "*",
41
41
  "react-native": "*"
42
42
  },
43
- "gitHead": "49c9d53cf0a9fc8179d1c8f5268beadd141f70ca"
43
+ "gitHead": "7638c800b57fe78f57cc7f129022f58e84a523c5"
44
44
  }