expo-audio 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/android/build.gradle +2 -2
- package/build/Audio.types.d.ts +11 -0
- package/build/Audio.types.d.ts.map +1 -1
- package/build/Audio.types.js.map +1 -1
- package/build/AudioModule.web.d.ts +3 -2
- package/build/AudioModule.web.d.ts.map +1 -1
- package/build/AudioModule.web.js +8 -3
- package/build/AudioModule.web.js.map +1 -1
- package/build/ExpoAudio.d.ts.map +1 -1
- package/build/ExpoAudio.js +12 -9
- package/build/ExpoAudio.js.map +1 -1
- package/build/ExpoAudio.web.js +4 -4
- package/build/ExpoAudio.web.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/AudioModule.swift +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.module → 1.0.1/expo.modules.audio-1.0.1.module} +7 -7
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.module.md5 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.pom → 1.0.1/expo.modules.audio-1.0.1.pom} +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.1/expo.modules.audio-1.0.1.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/maven-metadata.xml.sha512 +1 -1
- package/package.json +3 -3
- package/src/Audio.types.ts +11 -0
- package/src/AudioModule.web.ts +9 -3
- package/src/ExpoAudio.ts +13 -10
- package/src/ExpoAudio.web.ts +5 -5
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.module.md5 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/audio/expo.modules.audio/1.0.0/expo.modules.audio-1.0.0.pom.sha512 +0 -1
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0-sources.jar → 1.0.1/expo.modules.audio-1.0.1-sources.jar} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0-sources.jar.md5 → 1.0.1/expo.modules.audio-1.0.1-sources.jar.md5} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0-sources.jar.sha1 → 1.0.1/expo.modules.audio-1.0.1-sources.jar.sha1} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0-sources.jar.sha256 → 1.0.1/expo.modules.audio-1.0.1-sources.jar.sha256} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0-sources.jar.sha512 → 1.0.1/expo.modules.audio-1.0.1-sources.jar.sha512} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.aar → 1.0.1/expo.modules.audio-1.0.1.aar} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.aar.md5 → 1.0.1/expo.modules.audio-1.0.1.aar.md5} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.aar.sha1 → 1.0.1/expo.modules.audio-1.0.1.aar.sha1} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.aar.sha256 → 1.0.1/expo.modules.audio-1.0.1.aar.sha256} +0 -0
- /package/local-maven-repo/expo/modules/audio/expo.modules.audio/{1.0.0/expo.modules.audio-1.0.0.aar.sha512 → 1.0.1/expo.modules.audio-1.0.1.aar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.0.1 — 2025-08-15
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- [iOS] tvOS fixes. ([#38815](https://github.com/expo/expo/pull/38815) by [@douglowder](https://github.com/douglowder))
|
|
18
|
+
|
|
13
19
|
## 1.0.0 — 2025-08-13
|
|
14
20
|
|
|
15
21
|
### 🛠 Breaking changes
|
|
@@ -31,6 +37,7 @@
|
|
|
31
37
|
- [android][iOS][web] Fix recordForDuration status updates and add new record() options API ([#38612](https://github.com/expo/expo/pull/38612) by [@hirbod](https://github.com/hirbod))
|
|
32
38
|
- [android]: Handle exceptions when retrieving maxAmplitude from MediaRecorder ([#38690](https://github.com/expo/expo/pull/38690) by [@hirbod](https://github.com/hirbod))
|
|
33
39
|
- [iOS] Report correct playback rate. ([#38729](https://github.com/expo/expo/pull/38729) by [@aleqsio](https://github.com/aleqsio))
|
|
40
|
+
- [web] Added crossOrigin property to useAudioPlayer and createAudioPlayer ([#38818](https://github.com/expo/expo/pull/38818) by [@hirbod](https://github.com/hirbod)
|
|
34
41
|
|
|
35
42
|
### 💡 Others
|
|
36
43
|
|
package/android/build.gradle
CHANGED
package/build/Audio.types.d.ts
CHANGED
|
@@ -53,6 +53,17 @@ export type AudioPlayerOptions = {
|
|
|
53
53
|
* @platform android
|
|
54
54
|
*/
|
|
55
55
|
downloadFirst?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Determines the [cross origin policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin) used by the underlying native view on web.
|
|
58
|
+
* If `undefined` (default), does not use CORS at all. If set to `'anonymous'`, the audio will be loaded with CORS enabled.
|
|
59
|
+
* Note that some audio may not play if CORS is enabled, depending on the CDN settings.
|
|
60
|
+
* If you encounter issues, consider adjusting the `crossOrigin` property.
|
|
61
|
+
*
|
|
62
|
+
*
|
|
63
|
+
* @platform web
|
|
64
|
+
* @default undefined
|
|
65
|
+
*/
|
|
66
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
56
67
|
};
|
|
57
68
|
/**
|
|
58
69
|
* @deprecated Use `AudioPlayerOptions` instead.
|
|
@@ -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;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
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;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,qDAAqD;IACrD,IAAI,EAAE,MAAM,C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1
|
-
{"version":3,"file":"Audio.types.js","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"AA2MA;;;;;;;;;GASG;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;;;;;GAKG;AACH,MAAM,CAAN,IAAY,YAWX;AAXD,WAAY,YAAY;IACtB,4DAA4D;IAC5D,6CAAO,CAAA;IACP,sEAAsE;IACtE,8CAAU,CAAA;IACV,0DAA0D;IAC1D,oDAAa,CAAA;IACb,qDAAqD;IACrD,gDAAW,CAAA;IACX,yDAAyD;IACzD,+CAAU,CAAA;AACZ,CAAC,EAXW,YAAY,KAAZ,YAAY,QAWvB","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\n/**\n * Options for configuring audio player behavior.\n */\nexport type AudioPlayerOptions = {\n /**\n * How often (in milliseconds) to emit playback status updates.\n * @default 500\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n updateInterval?: number;\n /**\n * If set to `true`, the system will attempt to download the resource to the device before loading.\n * This value defaults to `false`.\n *\n * Works with:\n * - Local assets from `require('path/to/file')`\n * - Remote HTTP/HTTPS URLs\n * - Asset objects\n *\n * When enabled, this ensures the audio file is fully downloaded before playback begins.\n * This can improve playback performance and reduce buffering, especially for users\n * managing multiple audio players simultaneously.\n *\n * On Android and iOS, this will download the audio file to the device's tmp directory before playback begins.\n * The system will purge the file at its discretion.\n *\n * On web, this will download the audio file to the user's device memory and make it available for the user to play.\n * The system will usually purge the file from memory after a reload or on memory pressure.\n * On web, CORS restrictions apply to the blob url, so you need to make sure the server returns the `Access-Control-Allow-Origin` header.\n *\n * @platform ios\n * @platform web\n * @platform android\n */\n downloadFirst?: boolean;\n};\n\n/**\n * @deprecated Use `AudioPlayerOptions` instead.\n * Options for audio loading behavior.\n */\nexport type AudioLoadOptions = AudioPlayerOptions;\n\n/**\n * Represents an available audio input device for recording.\n *\n * This type describes audio input sources like built-in microphones, external microphones,\n * or other audio input devices that can be used for recording. Each input has an identifying\n * information that can be used to select the preferred recording source.\n */\nexport type RecordingInput = {\n /** Human-readable name of the audio input device. */\n name: string;\n /** Type or category of the input device (for example, 'Built-in Microphone', 'External Microphone'). */\n type: string;\n /** Unique identifier for the input device, used to select the input ('Built-in Microphone', 'External Microphone') for recording. */\n uid: string;\n};\n\n/**\n * Pitch correction quality settings for audio playback rate changes.\n *\n * When changing playback rate, pitch correction can be applied to maintain the original pitch.\n * Different quality levels offer trade-offs between processing power and audio quality.\n *\n * @platform ios\n */\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\n/**\n * Comprehensive status information for an `AudioPlayer`.\n *\n * This object contains all the current state information about audio playback,\n * including playback position, duration, loading state, and playback settings.\n * Used by `useAudioPlayerStatus()` to provide real-time status updates.\n */\nexport type AudioStatus = {\n /** Unique identifier for the player instance. */\n id: number;\n /** Current playback position in seconds. */\n currentTime: number;\n /** String representation of the player's internal playback state. */\n playbackState: string;\n /** String representation of the player's time control status (playing/paused/waiting). */\n timeControlStatus: string;\n /** Reason why the player is waiting to play (if applicable). */\n reasonForWaitingToPlay: string;\n /** Whether the player is currently muted. */\n mute: boolean;\n /** Total duration of the audio in seconds, or 0 if not yet determined. */\n duration: number;\n /** Whether the audio is currently playing. */\n playing: boolean;\n /** Whether the audio is set to loop when it reaches the end. */\n loop: boolean;\n /** Whether the audio just finished playing. */\n didJustFinish: boolean;\n /** Whether the player is currently buffering data. */\n isBuffering: boolean;\n /** Whether the audio has finished loading and is ready to play. */\n isLoaded: boolean;\n /** Current playback rate (1.0 = normal speed). */\n playbackRate: number;\n /** Whether pitch correction is enabled for rate changes. */\n shouldCorrectPitch: boolean;\n};\n\n/**\n * Status information for recording operations from the event system.\n *\n * This type represents the status data emitted by `recordingStatusUpdate` events.\n * It contains high-level information about the recording session and any errors.\n * Used internally by the event system. Most users should use `useAudioRecorderState()` instead.\n */\nexport type RecordingStatus = {\n /** Unique identifier for the recording session. */\n id: number;\n /** Whether the recording has finished (stopped). */\n isFinished: boolean;\n /** Whether an error occurred during recording. */\n hasError: boolean;\n /** Error message if an error occurred, `null` otherwise. */\n error: string | null;\n /** File URL of the completed recording, if available. */\n url: string | null;\n};\n\n/**\n * Current state information for an `AudioRecorder`.\n *\n * This object contains detailed information about the recorder's current state,\n * including recording status, duration, and technical details. This is what you get\n * when calling `recorder.getStatus()` or using `useAudioRecorderState()`.\n */\nexport type RecorderState = {\n /** Whether the recorder is ready and able to record. */\n canRecord: boolean;\n /** Whether recording is currently in progress. */\n isRecording: boolean;\n /** Duration of the current recording in milliseconds. */\n durationMillis: number;\n /** Whether the media services have been reset (typically indicates a system interruption). */\n mediaServicesDidReset: boolean;\n /** Current audio level/volume being recorded (if metering is enabled). */\n metering?: number;\n /** File URL where the recording will be saved, if available. */\n url: string | null;\n};\n\n/**\n * Audio output format options for Android recording.\n *\n * Specifies the container format for recorded audio files on Android.\n * Different formats have different compatibility and compression characteristics.\n *\n * @platform android\n */\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\n/**\n * Audio encoder options for Android recording.\n *\n * Specifies the audio codec used to encode recorded audio on Android.\n * Different encoders offer different quality, compression, and compatibility trade-offs.\n *\n * @platform android\n */\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\n/**\n * Audio output format options for iOS recording.\n *\n * Comprehensive enum of audio formats supported by iOS for recording.\n * Each format has different characteristics in terms of quality, file size, and compatibility.\n * Some formats like LINEARPCM offer the highest quality but larger file sizes,\n * while compressed formats like AAC provide good quality with smaller files.\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/**\n * Audio quality levels for recording.\n *\n * Predefined quality levels that balance file size and audio fidelity.\n * Higher quality levels produce better sound but larger files and require more processing power.\n */\nexport enum AudioQuality {\n /** Minimum quality: smallest file size, lowest fidelity. */\n MIN = 0,\n /** Low quality: good for voice recordings where file size matters. */\n LOW = 0x20,\n /** Medium quality: balanced option for most use cases. */\n MEDIUM = 0x40,\n /** High quality: good fidelity, larger file size. */\n HIGH = 0x60,\n /** Maximum quality: best fidelity, largest file size. */\n MAX = 0x7f,\n}\n\n/**\n * Bit rate strategies for audio encoding.\n *\n * Determines how the encoder manages bit rate during recording, affecting\n * file size consistency and quality characteristics.\n */\nexport type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';\n\n/**\n * Options for controlling how audio recording is started.\n */\nexport type RecordingStartOptions = {\n /**\n * The duration in seconds after which recording should automatically stop.\n * If not provided, recording continues until manually stopped.\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n forDuration?: number;\n /**\n * The time in seconds to wait before starting the recording.\n * If not provided, recording starts immediately.\n *\n * **Platform behavior:**\n * - Android: Ignored, recording starts immediately\n * - iOS: Uses native AVAudioRecorder.record(atTime:) for precise timing.\n * - Web: Ignored, recording starts immediately\n *\n * > **warning** On iOS, the recording process starts immediately (you'll see status updates),\n * but actual audio capture begins after the specified delay. This is not a countdown, since\n * the recorder is active but silent during the delay period.\n *\n * @platform ios\n */\n atTime?: number;\n};\n\nexport type RecordingOptions = {\n /**\n * A boolean that determines whether audio level information will be part of the status object under the \"metering\" key.\n */\n isMeteringEnabled?: boolean;\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate: number;\n /**\n * The desired number of channels.\n *\n * @example 2\n */\n numberOfChannels: number;\n /**\n * The desired bit rate.\n *\n * @example 128000\n */\n bitRate: number;\n /**\n * Recording options for the Android platform.\n * @platform android\n */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n * @platform ios\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n * @platform web\n */\n web?: RecordingOptionsWeb;\n};\n\n/**\n * Recording options for the web.\n *\n * Web recording uses the `MediaRecorder` API, which has different capabilities\n * compared to native platforms. These options map directly to `MediaRecorder` settings.\n *\n * @platform web\n */\nexport type RecordingOptionsWeb = {\n /** MIME type for the recording (for example, 'audio/webm', 'audio/mp4'). */\n mimeType?: string;\n /** Target bits per second for the recording. */\n bitsPerSecond?: number;\n};\n\n/**\n * Recording configuration options specific to iOS.\n *\n * iOS recording uses `AVAudioRecorder` with extensive format and quality options.\n * These settings provide fine-grained control over the recording characteristics.\n *\n * @platform ios\n */\nexport type RecordingOptionsIos = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.\n */\n outputFormat?: string | IOSOutputFormat | number;\n /**\n * The desired audio quality. See the [`AudioQuality`](#audioquality) enum for all valid values.\n */\n audioQuality: AudioQuality | number;\n /**\n * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.\n */\n bitRateStrategy?: number;\n /**\n * The desired bit depth hint.\n *\n * @example 16\n */\n bitDepthHint?: number;\n /**\n * The desired PCM bit depth.\n *\n * @example 16\n */\n linearPCMBitDepth?: number;\n /**\n * A boolean describing if the PCM data should be formatted in big endian.\n */\n linearPCMIsBigEndian?: boolean;\n /**\n * A boolean describing if the PCM data should be encoded in floating point or integral values.\n */\n linearPCMIsFloat?: boolean;\n};\n\n/**\n * Recording configuration options specific to Android.\n *\n * Android recording uses `MediaRecorder` with options for format, encoder, and file constraints.\n * These settings control the output format and quality characteristics.\n *\n * @platform android\n */\nexport type RecordingOptionsAndroid = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.\n */\n outputFormat: AndroidOutputFormat;\n /**\n * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.\n */\n audioEncoder: AndroidAudioEncoder;\n /**\n * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still\n * be called after this point).\n *\n * @example\n * `65536`\n */\n maxFileSize?: number;\n};\n\nexport type AudioMode = {\n /**\n * Determines if audio playback is allowed when the device is in silent mode.\n *\n * @platform ios\n */\n playsInSilentMode: boolean;\n /**\n * Determines how the audio session interacts with other sessions.\n *\n * @platform ios\n */\n interruptionMode: InterruptionMode;\n /**\n * Determines how the audio session interacts with other sessions on Android.\n *\n * @platform android\n */\n interruptionModeAndroid: InterruptionModeAndroid;\n /**\n * Whether the audio session allows recording.\n *\n * @default false\n * @platform ios\n */\n allowsRecording: boolean;\n /**\n * Whether the audio session stays active when the app moves to the background.\n * @default false\n */\n shouldPlayInBackground: boolean;\n /**\n * Whether the audio should route through the earpiece.\n * @platform android\n */\n shouldRouteThroughEarpiece: boolean;\n};\n\n/**\n * Audio interruption behavior modes for iOS.\n *\n * Controls how your app's audio interacts with other apps' audio when interruptions occur.\n * This affects what happens when phone calls, notifications, or other apps play audio.\n *\n * @platform ios\n */\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n\n/**\n * Audio interruption behavior modes for Android.\n *\n * Controls how your app's audio interacts with other apps' audio on Android.\n * Note that Android doesn't support 'mixWithOthers' mode; audio focus is more strictly managed.\n *\n * @platform android\n */\nexport type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';\n"]}
|
|
1
|
+
{"version":3,"file":"Audio.types.js","sourceRoot":"","sources":["../src/Audio.types.ts"],"names":[],"mappings":"AAsNA;;;;;;;;;GASG;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;;;;;GAKG;AACH,MAAM,CAAN,IAAY,YAWX;AAXD,WAAY,YAAY;IACtB,4DAA4D;IAC5D,6CAAO,CAAA;IACP,sEAAsE;IACtE,8CAAU,CAAA;IACV,0DAA0D;IAC1D,oDAAa,CAAA;IACb,qDAAqD;IACrD,gDAAW,CAAA;IACX,yDAAyD;IACzD,+CAAU,CAAA;AACZ,CAAC,EAXW,YAAY,KAAZ,YAAY,QAWvB","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\n/**\n * Options for configuring audio player behavior.\n */\nexport type AudioPlayerOptions = {\n /**\n * How often (in milliseconds) to emit playback status updates.\n * @default 500\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n updateInterval?: number;\n /**\n * If set to `true`, the system will attempt to download the resource to the device before loading.\n * This value defaults to `false`.\n *\n * Works with:\n * - Local assets from `require('path/to/file')`\n * - Remote HTTP/HTTPS URLs\n * - Asset objects\n *\n * When enabled, this ensures the audio file is fully downloaded before playback begins.\n * This can improve playback performance and reduce buffering, especially for users\n * managing multiple audio players simultaneously.\n *\n * On Android and iOS, this will download the audio file to the device's tmp directory before playback begins.\n * The system will purge the file at its discretion.\n *\n * On web, this will download the audio file to the user's device memory and make it available for the user to play.\n * The system will usually purge the file from memory after a reload or on memory pressure.\n * On web, CORS restrictions apply to the blob url, so you need to make sure the server returns the `Access-Control-Allow-Origin` header.\n *\n * @platform ios\n * @platform web\n * @platform android\n */\n downloadFirst?: boolean;\n /**\n * Determines the [cross origin policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin) used by the underlying native view on web.\n * If `undefined` (default), does not use CORS at all. If set to `'anonymous'`, the audio will be loaded with CORS enabled.\n * Note that some audio may not play if CORS is enabled, depending on the CDN settings.\n * If you encounter issues, consider adjusting the `crossOrigin` property.\n *\n *\n * @platform web\n * @default undefined\n */\n crossOrigin?: 'anonymous' | 'use-credentials';\n};\n\n/**\n * @deprecated Use `AudioPlayerOptions` instead.\n * Options for audio loading behavior.\n */\nexport type AudioLoadOptions = AudioPlayerOptions;\n\n/**\n * Represents an available audio input device for recording.\n *\n * This type describes audio input sources like built-in microphones, external microphones,\n * or other audio input devices that can be used for recording. Each input has an identifying\n * information that can be used to select the preferred recording source.\n */\nexport type RecordingInput = {\n /** Human-readable name of the audio input device. */\n name: string;\n /** Type or category of the input device (for example, 'Built-in Microphone', 'External Microphone'). */\n type: string;\n /** Unique identifier for the input device, used to select the input ('Built-in Microphone', 'External Microphone') for recording. */\n uid: string;\n};\n\n/**\n * Pitch correction quality settings for audio playback rate changes.\n *\n * When changing playback rate, pitch correction can be applied to maintain the original pitch.\n * Different quality levels offer trade-offs between processing power and audio quality.\n *\n * @platform ios\n */\nexport type PitchCorrectionQuality = 'low' | 'medium' | 'high';\n\n/**\n * Comprehensive status information for an `AudioPlayer`.\n *\n * This object contains all the current state information about audio playback,\n * including playback position, duration, loading state, and playback settings.\n * Used by `useAudioPlayerStatus()` to provide real-time status updates.\n */\nexport type AudioStatus = {\n /** Unique identifier for the player instance. */\n id: number;\n /** Current playback position in seconds. */\n currentTime: number;\n /** String representation of the player's internal playback state. */\n playbackState: string;\n /** String representation of the player's time control status (playing/paused/waiting). */\n timeControlStatus: string;\n /** Reason why the player is waiting to play (if applicable). */\n reasonForWaitingToPlay: string;\n /** Whether the player is currently muted. */\n mute: boolean;\n /** Total duration of the audio in seconds, or 0 if not yet determined. */\n duration: number;\n /** Whether the audio is currently playing. */\n playing: boolean;\n /** Whether the audio is set to loop when it reaches the end. */\n loop: boolean;\n /** Whether the audio just finished playing. */\n didJustFinish: boolean;\n /** Whether the player is currently buffering data. */\n isBuffering: boolean;\n /** Whether the audio has finished loading and is ready to play. */\n isLoaded: boolean;\n /** Current playback rate (1.0 = normal speed). */\n playbackRate: number;\n /** Whether pitch correction is enabled for rate changes. */\n shouldCorrectPitch: boolean;\n};\n\n/**\n * Status information for recording operations from the event system.\n *\n * This type represents the status data emitted by `recordingStatusUpdate` events.\n * It contains high-level information about the recording session and any errors.\n * Used internally by the event system. Most users should use `useAudioRecorderState()` instead.\n */\nexport type RecordingStatus = {\n /** Unique identifier for the recording session. */\n id: number;\n /** Whether the recording has finished (stopped). */\n isFinished: boolean;\n /** Whether an error occurred during recording. */\n hasError: boolean;\n /** Error message if an error occurred, `null` otherwise. */\n error: string | null;\n /** File URL of the completed recording, if available. */\n url: string | null;\n};\n\n/**\n * Current state information for an `AudioRecorder`.\n *\n * This object contains detailed information about the recorder's current state,\n * including recording status, duration, and technical details. This is what you get\n * when calling `recorder.getStatus()` or using `useAudioRecorderState()`.\n */\nexport type RecorderState = {\n /** Whether the recorder is ready and able to record. */\n canRecord: boolean;\n /** Whether recording is currently in progress. */\n isRecording: boolean;\n /** Duration of the current recording in milliseconds. */\n durationMillis: number;\n /** Whether the media services have been reset (typically indicates a system interruption). */\n mediaServicesDidReset: boolean;\n /** Current audio level/volume being recorded (if metering is enabled). */\n metering?: number;\n /** File URL where the recording will be saved, if available. */\n url: string | null;\n};\n\n/**\n * Audio output format options for Android recording.\n *\n * Specifies the container format for recorded audio files on Android.\n * Different formats have different compatibility and compression characteristics.\n *\n * @platform android\n */\nexport type AndroidOutputFormat =\n | 'default'\n | '3gp'\n | 'mpeg4'\n | 'amrnb'\n | 'amrwb'\n | 'aac_adts'\n | 'mpeg2ts'\n | 'webm';\n\n/**\n * Audio encoder options for Android recording.\n *\n * Specifies the audio codec used to encode recorded audio on Android.\n * Different encoders offer different quality, compression, and compatibility trade-offs.\n *\n * @platform android\n */\nexport type AndroidAudioEncoder = 'default' | 'amr_nb' | 'amr_wb' | 'aac' | 'he_aac' | 'aac_eld';\n\n/**\n * Audio output format options for iOS recording.\n *\n * Comprehensive enum of audio formats supported by iOS for recording.\n * Each format has different characteristics in terms of quality, file size, and compatibility.\n * Some formats like LINEARPCM offer the highest quality but larger file sizes,\n * while compressed formats like AAC provide good quality with smaller files.\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/**\n * Audio quality levels for recording.\n *\n * Predefined quality levels that balance file size and audio fidelity.\n * Higher quality levels produce better sound but larger files and require more processing power.\n */\nexport enum AudioQuality {\n /** Minimum quality: smallest file size, lowest fidelity. */\n MIN = 0,\n /** Low quality: good for voice recordings where file size matters. */\n LOW = 0x20,\n /** Medium quality: balanced option for most use cases. */\n MEDIUM = 0x40,\n /** High quality: good fidelity, larger file size. */\n HIGH = 0x60,\n /** Maximum quality: best fidelity, largest file size. */\n MAX = 0x7f,\n}\n\n/**\n * Bit rate strategies for audio encoding.\n *\n * Determines how the encoder manages bit rate during recording, affecting\n * file size consistency and quality characteristics.\n */\nexport type BitRateStrategy = 'constant' | 'longTermAverage' | 'variableConstrained' | 'variable';\n\n/**\n * Options for controlling how audio recording is started.\n */\nexport type RecordingStartOptions = {\n /**\n * The duration in seconds after which recording should automatically stop.\n * If not provided, recording continues until manually stopped.\n *\n * @platform ios\n * @platform android\n * @platform web\n */\n forDuration?: number;\n /**\n * The time in seconds to wait before starting the recording.\n * If not provided, recording starts immediately.\n *\n * **Platform behavior:**\n * - Android: Ignored, recording starts immediately\n * - iOS: Uses native AVAudioRecorder.record(atTime:) for precise timing.\n * - Web: Ignored, recording starts immediately\n *\n * > **warning** On iOS, the recording process starts immediately (you'll see status updates),\n * but actual audio capture begins after the specified delay. This is not a countdown, since\n * the recorder is active but silent during the delay period.\n *\n * @platform ios\n */\n atTime?: number;\n};\n\nexport type RecordingOptions = {\n /**\n * A boolean that determines whether audio level information will be part of the status object under the \"metering\" key.\n */\n isMeteringEnabled?: boolean;\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate: number;\n /**\n * The desired number of channels.\n *\n * @example 2\n */\n numberOfChannels: number;\n /**\n * The desired bit rate.\n *\n * @example 128000\n */\n bitRate: number;\n /**\n * Recording options for the Android platform.\n * @platform android\n */\n android: RecordingOptionsAndroid;\n /**\n * Recording options for the iOS platform.\n * @platform ios\n */\n ios: RecordingOptionsIos;\n /**\n * Recording options for the Web platform.\n * @platform web\n */\n web?: RecordingOptionsWeb;\n};\n\n/**\n * Recording options for the web.\n *\n * Web recording uses the `MediaRecorder` API, which has different capabilities\n * compared to native platforms. These options map directly to `MediaRecorder` settings.\n *\n * @platform web\n */\nexport type RecordingOptionsWeb = {\n /** MIME type for the recording (for example, 'audio/webm', 'audio/mp4'). */\n mimeType?: string;\n /** Target bits per second for the recording. */\n bitsPerSecond?: number;\n};\n\n/**\n * Recording configuration options specific to iOS.\n *\n * iOS recording uses `AVAudioRecorder` with extensive format and quality options.\n * These settings provide fine-grained control over the recording characteristics.\n *\n * @platform ios\n */\nexport type RecordingOptionsIos = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.\n */\n outputFormat?: string | IOSOutputFormat | number;\n /**\n * The desired audio quality. See the [`AudioQuality`](#audioquality) enum for all valid values.\n */\n audioQuality: AudioQuality | number;\n /**\n * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.\n */\n bitRateStrategy?: number;\n /**\n * The desired bit depth hint.\n *\n * @example 16\n */\n bitDepthHint?: number;\n /**\n * The desired PCM bit depth.\n *\n * @example 16\n */\n linearPCMBitDepth?: number;\n /**\n * A boolean describing if the PCM data should be formatted in big endian.\n */\n linearPCMIsBigEndian?: boolean;\n /**\n * A boolean describing if the PCM data should be encoded in floating point or integral values.\n */\n linearPCMIsFloat?: boolean;\n};\n\n/**\n * Recording configuration options specific to Android.\n *\n * Android recording uses `MediaRecorder` with options for format, encoder, and file constraints.\n * These settings control the output format and quality characteristics.\n *\n * @platform android\n */\nexport type RecordingOptionsAndroid = {\n /**\n * The desired file extension.\n *\n * @example .caf\n */\n extension?: string;\n /**\n * The desired sample rate.\n *\n * @example 44100\n */\n sampleRate?: number;\n /**\n * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.\n */\n outputFormat: AndroidOutputFormat;\n /**\n * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.\n */\n audioEncoder: AndroidAudioEncoder;\n /**\n * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still\n * be called after this point).\n *\n * @example\n * `65536`\n */\n maxFileSize?: number;\n};\n\nexport type AudioMode = {\n /**\n * Determines if audio playback is allowed when the device is in silent mode.\n *\n * @platform ios\n */\n playsInSilentMode: boolean;\n /**\n * Determines how the audio session interacts with other sessions.\n *\n * @platform ios\n */\n interruptionMode: InterruptionMode;\n /**\n * Determines how the audio session interacts with other sessions on Android.\n *\n * @platform android\n */\n interruptionModeAndroid: InterruptionModeAndroid;\n /**\n * Whether the audio session allows recording.\n *\n * @default false\n * @platform ios\n */\n allowsRecording: boolean;\n /**\n * Whether the audio session stays active when the app moves to the background.\n * @default false\n */\n shouldPlayInBackground: boolean;\n /**\n * Whether the audio should route through the earpiece.\n * @platform android\n */\n shouldRouteThroughEarpiece: boolean;\n};\n\n/**\n * Audio interruption behavior modes for iOS.\n *\n * Controls how your app's audio interacts with other apps' audio when interruptions occur.\n * This affects what happens when phone calls, notifications, or other apps play audio.\n *\n * @platform ios\n */\nexport type InterruptionMode = 'mixWithOthers' | 'doNotMix' | 'duckOthers';\n\n/**\n * Audio interruption behavior modes for Android.\n *\n * Controls how your app's audio interacts with other apps' audio on Android.\n * Note that Android doesn't support 'mixWithOthers' mode; audio focus is more strictly managed.\n *\n * @platform android\n */\nexport type InterruptionModeAndroid = 'doNotMix' | 'duckOthers';\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PermissionResponse } from 'expo-modules-core';
|
|
2
|
-
import { AudioMode, AudioSource, AudioStatus, PitchCorrectionQuality, RecorderState, RecordingInput, RecordingOptions, RecordingStartOptions } from './Audio.types';
|
|
2
|
+
import { AudioMode, AudioPlayerOptions, AudioSource, AudioStatus, PitchCorrectionQuality, RecorderState, RecordingInput, RecordingOptions, RecordingStartOptions } from './Audio.types';
|
|
3
3
|
import { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';
|
|
4
4
|
export declare class AudioPlayerWeb extends globalThis.expo.SharedObject<AudioEvents> implements AudioPlayer {
|
|
5
|
-
constructor(source: AudioSource,
|
|
5
|
+
constructor(source: AudioSource, options?: AudioPlayerOptions);
|
|
6
6
|
id: number;
|
|
7
7
|
isAudioSamplingSupported: boolean;
|
|
8
8
|
isBuffering: boolean;
|
|
@@ -12,6 +12,7 @@ export declare class AudioPlayerWeb extends globalThis.expo.SharedObject<AudioEv
|
|
|
12
12
|
private interval;
|
|
13
13
|
private isPlaying;
|
|
14
14
|
private loaded;
|
|
15
|
+
private crossOrigin?;
|
|
15
16
|
get playing(): boolean;
|
|
16
17
|
get muted(): boolean;
|
|
17
18
|
set muted(value: boolean);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioModule.web.d.ts","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAwF/F,qBAAa,cACX,SAAQ,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAChD,YAAW,WAAW;gBAEV,MAAM,EAAE,WAAW,EAAE,
|
|
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,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAwF/F,qBAAa,cACX,SAAQ,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAChD,YAAW,WAAW;gBAEV,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,kBAAuB;IASjE,EAAE,EAAE,MAAM,CAAY;IACtB,wBAAwB,UA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
|
}
|
|
77
77
|
export class AudioPlayerWeb extends globalThis.expo.SharedObject {
|
|
78
|
-
constructor(source,
|
|
78
|
+
constructor(source, options = {}) {
|
|
79
79
|
super();
|
|
80
|
+
const { updateInterval = 500, crossOrigin } = options;
|
|
80
81
|
this.src = source;
|
|
81
|
-
this.interval = Math.max(
|
|
82
|
+
this.interval = Math.max(updateInterval, 1);
|
|
83
|
+
this.crossOrigin = crossOrigin;
|
|
82
84
|
this.media = this._createMediaElement();
|
|
83
85
|
}
|
|
84
86
|
id = nextId();
|
|
@@ -90,6 +92,7 @@ export class AudioPlayerWeb extends globalThis.expo.SharedObject {
|
|
|
90
92
|
interval = 500;
|
|
91
93
|
isPlaying = false;
|
|
92
94
|
loaded = false;
|
|
95
|
+
crossOrigin;
|
|
93
96
|
get playing() {
|
|
94
97
|
return this.isPlaying;
|
|
95
98
|
}
|
|
@@ -174,7 +177,9 @@ export class AudioPlayerWeb extends globalThis.expo.SharedObject {
|
|
|
174
177
|
_createMediaElement() {
|
|
175
178
|
const newSource = getSourceUri(this.src);
|
|
176
179
|
const media = new Audio(newSource);
|
|
177
|
-
|
|
180
|
+
if (this.crossOrigin !== undefined) {
|
|
181
|
+
media.crossOrigin = this.crossOrigin;
|
|
182
|
+
}
|
|
178
183
|
let lastEmitTime = 0;
|
|
179
184
|
const intervalSec = this.interval / 1000;
|
|
180
185
|
// Throttled status updates based on interval
|
|
@@ -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,kBAAkB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;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I,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 RecordingStartOptions,\n} from './Audio.types';\nimport { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './AudioEventKeys';\nimport { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';\nimport { RecordingPresets } from './RecordingConstants';\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 = Math.max(interval, 1);\n this.media = this._createMediaElement();\n }\n\n id: number = nextId();\n isAudioSamplingSupported = false;\n isBuffering = false;\n shouldCorrectPitch = false;\n\n private src: AudioSource = null;\n private media: HTMLAudioElement;\n private interval = 500;\n private isPlaying = false;\n private loaded = false;\n\n get playing(): boolean {\n return this.isPlaying;\n }\n\n get muted(): boolean {\n return this.media.muted;\n }\n\n set muted(value: boolean) {\n this.media.muted = value;\n }\n\n get loop(): boolean {\n return this.media.loop;\n }\n\n set loop(value: boolean) {\n this.media.loop = value;\n }\n\n get duration(): number {\n return this.media.duration;\n }\n\n get currentTime(): number {\n return this.media.currentTime;\n }\n\n get paused(): boolean {\n return this.media.paused;\n }\n\n get isLoaded(): boolean {\n return this.loaded;\n }\n\n get playbackRate(): number {\n return this.media.playbackRate;\n }\n\n set playbackRate(value: number) {\n this.media.playbackRate = value;\n }\n\n get volume(): number {\n return this.media.volume;\n }\n\n set volume(value: number) {\n this.media.volume = value;\n }\n\n get currentStatus(): AudioStatus {\n return getStatusFromMedia(this.media, this.id);\n }\n\n play(): void {\n this.media.play();\n this.isPlaying = true;\n }\n\n pause(): void {\n this.media.pause();\n this.isPlaying = false;\n }\n\n replace(source: AudioSource): void {\n const wasPlaying = this.isPlaying;\n\n // we need to remove the current media element and create a new one\n this.remove();\n\n this.src = source;\n this.isPlaying = false;\n this.loaded = false;\n this.media = this._createMediaElement();\n\n // Resume playback if it was playing before\n if (wasPlaying) {\n this.play();\n }\n }\n\n async seekTo(\n seconds: number,\n toleranceMillisBefore?: number,\n toleranceMillisAfter?: number\n ): Promise<void> {\n this.media.currentTime = seconds;\n }\n\n // Not supported on web\n setAudioSamplingEnabled(enabled: boolean): void {\n this.isAudioSamplingSupported = false;\n }\n\n setPlaybackRate(second: number, pitchCorrectionQuality?: PitchCorrectionQuality): void {\n this.media.playbackRate = second;\n this.shouldCorrectPitch = pitchCorrectionQuality === 'high';\n this.media.preservesPitch = this.shouldCorrectPitch;\n }\n\n remove(): void {\n this.media.pause();\n this.media.removeAttribute('src');\n this.media.load();\n getStatusFromMedia(this.media, this.id);\n }\n\n _createMediaElement() {\n const newSource = getSourceUri(this.src);\n const media = new Audio(newSource);\n media.crossOrigin = 'anonymous';\n\n let lastEmitTime = 0;\n const intervalSec = this.interval / 1000;\n\n // Throttled status updates based on interval\n media.ontimeupdate = () => {\n const now = media.currentTime;\n // Handle backwards time (loop/seek)\n if (now < lastEmitTime) {\n lastEmitTime = now;\n }\n if (now - lastEmitTime >= intervalSec) {\n lastEmitTime = now;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n }\n };\n\n media.onplay = () => {\n this.isPlaying = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onpause = () => {\n this.isPlaying = false;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onseeked = () => {\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n };\n\n media.onended = () => {\n lastEmitTime = 0;\n };\n\n media.onloadeddata = () => {\n this.loaded = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n isLoaded: this.loaded,\n });\n };\n\n return media;\n }\n}\n\nfunction getSourceUri(source: AudioSource): string | undefined {\n if (typeof source === 'string') {\n return source;\n }\n if (typeof source === 'number') {\n 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(options?: RecordingStartOptions): void {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n // Clear any existing timeouts\n this.clearTimeouts();\n\n // Note: atTime is not supported on Web (no native equivalent), so we ignore it entirely\n // Only forDuration is implemented using setTimeout\n const { forDuration } = options || {};\n\n this.startActualRecording();\n\n if (forDuration !== undefined) {\n this.timeoutIds.push(\n setTimeout(() => {\n this.stop();\n }, forDuration * 1000)\n );\n }\n }\n\n private startActualRecording(): void {\n if (this.mediaRecorder?.state === 'paused') {\n this.mediaRecorder.resume();\n } else {\n this.mediaRecorder?.start();\n }\n }\n\n getAvailableInputs(): RecordingInput[] {\n return [];\n }\n\n getCurrentInput(): 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({ forDuration: seconds });\n }\n\n setInput(input: string): void {}\n\n startRecordingAtTime(seconds: number): void {\n this.record({ atTime: seconds });\n }\n\n async stop(): Promise<void> {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n const dataPromise = new Promise<Blob>((resolve) =>\n this.mediaRecorder?.addEventListener('dataavailable', (e) => resolve(e.data))\n );\n\n this.mediaRecorder?.stop();\n this.mediaRecorder = null;\n\n const data = await dataPromise;\n const url = URL.createObjectURL(data);\n\n this.uri = url;\n\n this.emit(RECORDING_STATUS_UPDATE, {\n id: this.id,\n isFinished: true,\n hasError: false,\n error: null,\n url,\n });\n }\n\n clearTimeouts() {\n this.timeoutIds.forEach((id) => clearTimeout(id));\n }\n\n private async createMediaRecorder(options: Partial<RecordingOptions>): Promise<MediaRecorder> {\n if (typeof navigator !== 'undefined' && !navigator.mediaDevices) {\n throw new Error('No media devices available');\n }\n\n this.mediaRecorderUptimeOfLastStartResume = 0;\n this.currentTime = 0;\n\n const stream = await getUserMedia({ audio: true });\n\n const mediaRecorder = new (window as any).MediaRecorder(\n stream,\n options?.web || RecordingPresets.HIGH_QUALITY.web\n );\n\n mediaRecorder.addEventListener('pause', () => {\n this.currentTime = this.getAudioRecorderDurationMillis();\n this.mediaRecorderIsRecording = false;\n });\n\n mediaRecorder.addEventListener('resume', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder.addEventListener('start', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.currentTime = 0;\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder?.addEventListener('stop', () => {\n this.currentTime = 0;\n this.mediaRecorderIsRecording = false;\n\n // Clears recording icon in Chrome tab\n stream.getTracks().forEach((track) => track.stop());\n });\n\n return mediaRecorder;\n }\n\n private getAudioRecorderDurationMillis() {\n let duration = this.currentTime;\n if (this.mediaRecorderIsRecording && this.mediaRecorderUptimeOfLastStartResume > 0) {\n duration += Date.now() - this.mediaRecorderUptimeOfLastStartResume;\n }\n return duration;\n }\n}\n\nexport async function setAudioModeAsync(mode: AudioMode) {}\nexport async function setIsAudioActiveAsync(active: boolean) {}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n const maybeStatus = await getPermissionWithQueryAsync('microphone');\n switch (maybeStatus) {\n case PermissionStatus.GRANTED:\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n case PermissionStatus.DENIED:\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n default:\n return await requestRecordingPermissionsAsync();\n }\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n try {\n const stream = await getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch {\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AudioModule.web.js","sourceRoot":"","sources":["../src/AudioModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAazE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,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,UAAU,2BAA2B,CACxC,IAAwC;IAExC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAEtF,IAAI,CAAC;QACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAA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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 AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingInput,\n RecordingOptions,\n RecordingStartOptions,\n} from './Audio.types';\nimport { PLAYBACK_STATUS_UPDATE, RECORDING_STATUS_UPDATE } from './AudioEventKeys';\nimport { AudioPlayer, AudioEvents, RecordingEvents, AudioRecorder } from './AudioModule.types';\nimport { RecordingPresets } from './RecordingConstants';\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, options: AudioPlayerOptions = {}) {\n super();\n const { updateInterval = 500, crossOrigin } = options;\n this.src = source;\n this.interval = Math.max(updateInterval, 1);\n this.crossOrigin = crossOrigin;\n this.media = this._createMediaElement();\n }\n\n id: number = nextId();\n isAudioSamplingSupported = false;\n isBuffering = false;\n shouldCorrectPitch = false;\n\n private src: AudioSource = null;\n private media: HTMLAudioElement;\n private interval = 500;\n private isPlaying = false;\n private loaded = false;\n private crossOrigin?: 'anonymous' | 'use-credentials';\n\n get playing(): boolean {\n return this.isPlaying;\n }\n\n get muted(): boolean {\n return this.media.muted;\n }\n\n set muted(value: boolean) {\n this.media.muted = value;\n }\n\n get loop(): boolean {\n return this.media.loop;\n }\n\n set loop(value: boolean) {\n this.media.loop = value;\n }\n\n get duration(): number {\n return this.media.duration;\n }\n\n get currentTime(): number {\n return this.media.currentTime;\n }\n\n get paused(): boolean {\n return this.media.paused;\n }\n\n get isLoaded(): boolean {\n return this.loaded;\n }\n\n get playbackRate(): number {\n return this.media.playbackRate;\n }\n\n set playbackRate(value: number) {\n this.media.playbackRate = value;\n }\n\n get volume(): number {\n return this.media.volume;\n }\n\n set volume(value: number) {\n this.media.volume = value;\n }\n\n get currentStatus(): AudioStatus {\n return getStatusFromMedia(this.media, this.id);\n }\n\n play(): void {\n this.media.play();\n this.isPlaying = true;\n }\n\n pause(): void {\n this.media.pause();\n this.isPlaying = false;\n }\n\n replace(source: AudioSource): void {\n const wasPlaying = this.isPlaying;\n\n // we need to remove the current media element and create a new one\n this.remove();\n\n this.src = source;\n this.isPlaying = false;\n this.loaded = false;\n this.media = this._createMediaElement();\n\n // Resume playback if it was playing before\n if (wasPlaying) {\n this.play();\n }\n }\n\n async seekTo(\n seconds: number,\n toleranceMillisBefore?: number,\n toleranceMillisAfter?: number\n ): Promise<void> {\n this.media.currentTime = seconds;\n }\n\n // Not supported on web\n setAudioSamplingEnabled(enabled: boolean): void {\n this.isAudioSamplingSupported = false;\n }\n\n setPlaybackRate(second: number, pitchCorrectionQuality?: PitchCorrectionQuality): void {\n this.media.playbackRate = second;\n this.shouldCorrectPitch = pitchCorrectionQuality === 'high';\n this.media.preservesPitch = this.shouldCorrectPitch;\n }\n\n remove(): void {\n this.media.pause();\n this.media.removeAttribute('src');\n this.media.load();\n getStatusFromMedia(this.media, this.id);\n }\n\n _createMediaElement() {\n const newSource = getSourceUri(this.src);\n const media = new Audio(newSource);\n if (this.crossOrigin !== undefined) {\n media.crossOrigin = this.crossOrigin;\n }\n\n let lastEmitTime = 0;\n const intervalSec = this.interval / 1000;\n\n // Throttled status updates based on interval\n media.ontimeupdate = () => {\n const now = media.currentTime;\n // Handle backwards time (loop/seek)\n if (now < lastEmitTime) {\n lastEmitTime = now;\n }\n if (now - lastEmitTime >= intervalSec) {\n lastEmitTime = now;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n }\n };\n\n media.onplay = () => {\n this.isPlaying = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onpause = () => {\n this.isPlaying = false;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n playing: this.isPlaying,\n });\n };\n\n media.onseeked = () => {\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, getStatusFromMedia(media, this.id));\n };\n\n media.onended = () => {\n lastEmitTime = 0;\n };\n\n media.onloadeddata = () => {\n this.loaded = true;\n lastEmitTime = media.currentTime;\n this.emit(PLAYBACK_STATUS_UPDATE, {\n ...getStatusFromMedia(media, this.id),\n isLoaded: this.loaded,\n });\n };\n\n return media;\n }\n}\n\nfunction getSourceUri(source: AudioSource): string | undefined {\n if (typeof source === 'string') {\n return source;\n }\n if (typeof source === 'number') {\n 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(options?: RecordingStartOptions): void {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n // Clear any existing timeouts\n this.clearTimeouts();\n\n // Note: atTime is not supported on Web (no native equivalent), so we ignore it entirely\n // Only forDuration is implemented using setTimeout\n const { forDuration } = options || {};\n\n this.startActualRecording();\n\n if (forDuration !== undefined) {\n this.timeoutIds.push(\n setTimeout(() => {\n this.stop();\n }, forDuration * 1000)\n );\n }\n }\n\n private startActualRecording(): void {\n if (this.mediaRecorder?.state === 'paused') {\n this.mediaRecorder.resume();\n } else {\n this.mediaRecorder?.start();\n }\n }\n\n getAvailableInputs(): RecordingInput[] {\n return [];\n }\n\n getCurrentInput(): 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({ forDuration: seconds });\n }\n\n setInput(input: string): void {}\n\n startRecordingAtTime(seconds: number): void {\n this.record({ atTime: seconds });\n }\n\n async stop(): Promise<void> {\n if (this.mediaRecorder === null) {\n throw new Error(\n 'Cannot start an audio recording without initializing a MediaRecorder. Run prepareToRecordAsync() before attempting to start an audio recording.'\n );\n }\n\n const dataPromise = new Promise<Blob>((resolve) =>\n this.mediaRecorder?.addEventListener('dataavailable', (e) => resolve(e.data))\n );\n\n this.mediaRecorder?.stop();\n this.mediaRecorder = null;\n\n const data = await dataPromise;\n const url = URL.createObjectURL(data);\n\n this.uri = url;\n\n this.emit(RECORDING_STATUS_UPDATE, {\n id: this.id,\n isFinished: true,\n hasError: false,\n error: null,\n url,\n });\n }\n\n clearTimeouts() {\n this.timeoutIds.forEach((id) => clearTimeout(id));\n }\n\n private async createMediaRecorder(options: Partial<RecordingOptions>): Promise<MediaRecorder> {\n if (typeof navigator !== 'undefined' && !navigator.mediaDevices) {\n throw new Error('No media devices available');\n }\n\n this.mediaRecorderUptimeOfLastStartResume = 0;\n this.currentTime = 0;\n\n const stream = await getUserMedia({ audio: true });\n\n const mediaRecorder = new (window as any).MediaRecorder(\n stream,\n options?.web || RecordingPresets.HIGH_QUALITY.web\n );\n\n mediaRecorder.addEventListener('pause', () => {\n this.currentTime = this.getAudioRecorderDurationMillis();\n this.mediaRecorderIsRecording = false;\n });\n\n mediaRecorder.addEventListener('resume', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder.addEventListener('start', () => {\n this.mediaRecorderUptimeOfLastStartResume = Date.now();\n this.currentTime = 0;\n this.mediaRecorderIsRecording = true;\n });\n\n mediaRecorder?.addEventListener('stop', () => {\n this.currentTime = 0;\n this.mediaRecorderIsRecording = false;\n\n // Clears recording icon in Chrome tab\n stream.getTracks().forEach((track) => track.stop());\n });\n\n return mediaRecorder;\n }\n\n private getAudioRecorderDurationMillis() {\n let duration = this.currentTime;\n if (this.mediaRecorderIsRecording && this.mediaRecorderUptimeOfLastStartResume > 0) {\n duration += Date.now() - this.mediaRecorderUptimeOfLastStartResume;\n }\n return duration;\n }\n}\n\nexport async function setAudioModeAsync(mode: AudioMode) {}\nexport async function setIsAudioActiveAsync(active: boolean) {}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n const maybeStatus = await getPermissionWithQueryAsync('microphone');\n switch (maybeStatus) {\n case PermissionStatus.GRANTED:\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n case PermissionStatus.DENIED:\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n default:\n return await requestRecordingPermissionsAsync();\n }\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n try {\n const stream = await getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch {\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n"]}
|
package/build/ExpoAudio.d.ts.map
CHANGED
|
@@ -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,kBAAkB,EAClB,WAAW,EACX,WAAW,EAEX,aAAa,EACb,gBAAgB,EAEhB,eAAe,EAChB,MAAM,eAAe,CAAC;AAMvB,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,kBAAkB,EAClB,WAAW,EACX,WAAW,EAEX,aAAa,EACb,gBAAgB,EAEhB,eAAe,EAChB,MAAM,eAAe,CAAC;AAMvB,OAAO,WAA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;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEpF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAEhF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/build/ExpoAudio.js
CHANGED
|
@@ -20,15 +20,18 @@ AudioModule.AudioPlayer.prototype.setPlaybackRate = function (rate, pitchCorrect
|
|
|
20
20
|
return setPlaybackRate.call(this, rate, pitchCorrectionQuality);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// Audio recording prototypes should not be shimmed on tvOS, where they do not exist
|
|
24
|
+
if (!Platform.isTV || Platform.OS !== 'ios') {
|
|
25
|
+
const prepareToRecordAsync = AudioModule.AudioRecorder.prototype.prepareToRecordAsync;
|
|
26
|
+
AudioModule.AudioRecorder.prototype.prepareToRecordAsync = function (options) {
|
|
27
|
+
const processedOptions = options ? createRecordingOptions(options) : undefined;
|
|
28
|
+
return prepareToRecordAsync.call(this, processedOptions);
|
|
29
|
+
};
|
|
30
|
+
const record = AudioModule.AudioRecorder.prototype.record;
|
|
31
|
+
AudioModule.AudioRecorder.prototype.record = function (options) {
|
|
32
|
+
return record.call(this, options);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
32
35
|
/**
|
|
33
36
|
* Creates an `AudioPlayer` instance that automatically releases when the component unmounts.
|
|
34
37
|
*
|
package/build/ExpoAudio.js.map
CHANGED
|
@@ -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,EAAs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AAS,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,MAAM,WAAW,CAAC,gCAAgC,EAAE,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,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 AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingOptions,\n RecordingStartOptions,\n RecordingStatus,\n} from './Audio.types';\nimport {\n AUDIO_SAMPLE_UPDATE,\n PLAYBACK_STATUS_UPDATE,\n RECORDING_STATUS_UPDATE,\n} from './AudioEventKeys';\nimport AudioModule from './AudioModule';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource, resolveSourceWithDownload } from './utils/resolveSource';\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\nconst setPlaybackRate = AudioModule.AudioPlayer.prototype.setPlaybackRate;\nAudioModule.AudioPlayer.prototype.setPlaybackRate = function (\n rate: number,\n pitchCorrectionQuality?: PitchCorrectionQuality\n) {\n if (Platform.OS === 'android') {\n return setPlaybackRate.call(this, rate);\n } else {\n return setPlaybackRate.call(this, rate, pitchCorrectionQuality);\n }\n};\n\nconst prepareToRecordAsync = AudioModule.AudioRecorder.prototype.prepareToRecordAsync;\nAudioModule.AudioRecorder.prototype.prepareToRecordAsync = function (options?: RecordingOptions) {\n const processedOptions = options ? createRecordingOptions(options) : undefined;\n return prepareToRecordAsync.call(this, processedOptions);\n};\n\nconst record = AudioModule.AudioRecorder.prototype.record;\nAudioModule.AudioRecorder.prototype.record = function (options?: RecordingStartOptions) {\n return record.call(this, options);\n};\n\n/**\n * Creates an `AudioPlayer` instance that automatically releases when the component unmounts.\n *\n * This hook manages the player's lifecycle and ensures it's properly disposed when no longer needed.\n * The player will start loading the audio source immediately upon creation.\n *\n * @param source The audio source to load. Can be a local asset via `require()`, a remote URL, or null for no initial source.\n * @param options Audio player configuration options.\n * @returns An `AudioPlayer` instance that's automatically managed by the component lifecycle.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer } from 'expo-audio';\n *\n * function MyComponent() {\n * const player = useAudioPlayer(require('./sound.mp3'));\n *\n * return (\n * <Button title=\"Play\" onPress={() => player.play()} />\n * );\n * }\n * ```\n *\n * @example Using downloadFirst\n * ```tsx\n * import { useAudioPlayer } from 'expo-audio';\n *\n * function MyComponent() {\n * const player = useAudioPlayer('https://example.com/audio.mp3', {\n * updateInterval: 1000,\n * downloadFirst: true,\n * });\n *\n * return (\n * <Button title=\"Play\" onPress={() => player.play()} />\n * );\n * }\n * ```\n */\nexport function useAudioPlayer(\n source: AudioSource = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { updateInterval = 500, downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.\n // If downloadFirst is false, we resolve the source here.\n // we call .replace() in the useEffect below to replace the source with the downloaded one.\n const initialSource = useMemo(() => {\n return downloadFirst ? null : resolveSource(source);\n }, [JSON.stringify(source), downloadFirst]);\n\n const player = useReleasingSharedObject(\n () => new AudioModule.AudioPlayer(initialSource, updateInterval),\n [JSON.stringify(initialSource), updateInterval]\n );\n\n // Handle async source resolution for downloadFirst\n useEffect(() => {\n if (!downloadFirst || source === null) {\n return;\n }\n\n let isCancelled = false;\n\n // We resolve the source with expo-asset and replace the player's source with the downloaded one.\n async function resolveAndReplaceSource() {\n try {\n const resolved = await resolveSourceWithDownload(source);\n\n if (\n !isCancelled &&\n resolved &&\n JSON.stringify(resolved) !== JSON.stringify(initialSource)\n ) {\n player.replace(resolved);\n }\n } catch (error) {\n if (!isCancelled) {\n console.warn('expo-audio: Failed to download source, using original:', error);\n }\n }\n }\n\n resolveAndReplaceSource();\n\n return () => {\n isCancelled = true;\n };\n }, [player, JSON.stringify(source), downloadFirst]);\n\n return player;\n}\n\n/**\n * Hook that provides real-time playback status updates for an `AudioPlayer`.\n *\n * This hook automatically subscribes to playback status changes and returns the current status.\n * The status includes information about playback state, current time, duration, loading state, and more.\n *\n * @param player The `AudioPlayer` instance to monitor.\n * @returns The current `AudioStatus` object containing playback information.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer, useAudioPlayerStatus } from 'expo-audio';\n *\n * function PlayerComponent() {\n * const player = useAudioPlayer(require('./sound.mp3'));\n * const status = useAudioPlayerStatus(player);\n *\n * return (\n * <View>\n * <Text>Playing: {status.isPlaying ? 'Yes' : 'No'}</Text>\n * <Text>Current Time: {status.currentTime}s</Text>\n * <Text>Duration: {status.duration}s</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\n/**\n * Hook that sets up audio sampling for an `AudioPlayer` and calls a listener with audio data.\n *\n * This hook enables audio sampling on the player (if supported) and subscribes to audio sample updates.\n * Audio sampling provides real-time access to audio waveform data for visualization or analysis.\n *\n * > **Note:** Audio sampling requires `RECORD_AUDIO` permission on Android and is not supported on all platforms.\n *\n * @param player The `AudioPlayer` instance to sample audio from.\n * @param listener Function called with each audio sample containing waveform data.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer, useAudioSampleListener } from 'expo-audio';\n *\n * function AudioVisualizerComponent() {\n * const player = useAudioPlayer(require('./music.mp3'));\n *\n * useAudioSampleListener(player, (sample) => {\n * // Use sample.channels array for audio visualization\n * console.log('Audio sample:', sample.channels[0].frames);\n * });\n *\n * return <AudioWaveform player={player} />;\n * }\n * ```\n */\nexport function useAudioSampleListener(player: AudioPlayer, listener: (data: AudioSample) => void) {\n useEffect(() => {\n if (!player.isAudioSamplingSupported) {\n return;\n }\n player.setAudioSamplingEnabled(true);\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => subscription.remove();\n }, [player.id]);\n}\n\n/**\n * Hook that creates an `AudioRecorder` instance for recording audio.\n *\n * This hook manages the recorder's lifecycle and ensures it's properly disposed when no longer needed.\n * The recorder is automatically prepared with the provided options and can be used to record audio.\n *\n * @param options Recording configuration options including format, quality, sample rate, etc.\n * @param statusListener Optional callback function that receives recording status updates.\n * @returns An `AudioRecorder` instance that's automatically managed by the component lifecycle.\n *\n * @example\n * ```tsx\n * import { useAudioRecorder, RecordingPresets } from 'expo-audio';\n *\n * function RecorderComponent() {\n * const recorder = useAudioRecorder(\n * RecordingPresets.HIGH_QUALITY,\n * (status) => console.log('Recording status:', status)\n * );\n *\n * const startRecording = async () => {\n * await recorder.prepareToRecordAsync();\n * recorder.record();\n * };\n *\n * return (\n * <Button title=\"Start Recording\" onPress={startRecording} />\n * );\n * }\n * ```\n */\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioRecorder {\n const platformOptions = createRecordingOptions(options);\n const recorder = useReleasingSharedObject(() => {\n return new AudioModule.AudioRecorder(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => subscription.remove();\n }, [recorder.id]);\n\n return recorder;\n}\n\n/**\n * Hook that provides real-time recording state updates for an `AudioRecorder`.\n *\n * This hook polls the recorder's status at regular intervals and returns the current recording state.\n * Use this when you need to monitor the recording status without setting up a status listener.\n *\n * @param recorder The `AudioRecorder` instance to monitor.\n * @param interval How often (in milliseconds) to poll the recorder's status. Defaults to 500ms.\n * @returns The current `RecorderState` containing recording information.\n *\n * @example\n * ```tsx\n * import { useAudioRecorder, useAudioRecorderState, RecordingPresets } from 'expo-audio';\n *\n * function RecorderStatusComponent() {\n * const recorder = useAudioRecorder(RecordingPresets.HIGH_QUALITY);\n * const state = useAudioRecorderState(recorder);\n *\n * return (\n * <View>\n * <Text>Recording: {state.isRecording ? 'Yes' : 'No'}</Text>\n * <Text>Duration: {state.currentTime}s</Text>\n * <Text>Can Record: {state.canRecord ? 'Yes' : 'No'}</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport function useAudioRecorderState(recorder: AudioRecorder, interval: number = 500) {\n const [state, setState] = useState<RecorderState>(recorder.getStatus());\n\n useEffect(() => {\n const int = setInterval(() => {\n const newState = recorder.getStatus();\n\n setState((prevState) => {\n const meteringChanged =\n (prevState.metering === undefined) !== (newState.metering === undefined) ||\n (prevState.metering !== undefined &&\n newState.metering !== undefined &&\n Math.abs(prevState.metering - newState.metering) > 0.1);\n\n if (\n prevState.canRecord !== newState.canRecord ||\n prevState.isRecording !== newState.isRecording ||\n prevState.mediaServicesDidReset !== newState.mediaServicesDidReset ||\n prevState.url !== newState.url ||\n Math.abs(prevState.durationMillis - newState.durationMillis) > 50 ||\n meteringChanged\n ) {\n return newState;\n }\n return prevState;\n });\n }, interval);\n\n return () => clearInterval(int);\n }, [recorder.id]);\n\n return state;\n}\n\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`](#useaudioplayer) hook instead.\n * > See the [Using the `AudioPlayer` directly](#using-the-audioplayer-directly) section for more details.\n * @param source The audio source to load.\n * @param options Audio player configuration options.\n */\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { updateInterval = 500, downloadFirst = false } = options;\n const initialSource = downloadFirst ? null : resolveSource(source);\n const player = new AudioModule.AudioPlayer(initialSource, updateInterval);\n\n if (downloadFirst && source) {\n resolveSourceWithDownload(source)\n .then((resolved) => {\n if (resolved) {\n player.replace(resolved);\n }\n })\n .catch((error) => {\n console.warn('expo-audio: Failed to download source, using fallback:', error);\n const fallback = resolveSource(source);\n if (fallback) {\n player.replace(fallback);\n }\n });\n }\n\n return player;\n}\n\n/**\n * Enables or disables the audio subsystem globally.\n *\n * When set to `false`, this will pause all audio playback and prevent new audio from playing.\n * This is useful for implementing app-wide audio controls or responding to system events.\n *\n * @param active Whether audio should be active (`true`) or disabled (`false`).\n * @returns A Promise that resolves when the audio state has been updated.\n *\n * @example\n * ```tsx\n * import { setIsAudioActiveAsync } from 'expo-audio';\n *\n * // Disable all audio when app goes to background\n * const handleAppStateChange = async (nextAppState) => {\n * if (nextAppState === 'background') {\n * await setIsAudioActiveAsync(false);\n * } else if (nextAppState === 'active') {\n * await setIsAudioActiveAsync(true);\n * }\n * };\n * ```\n */\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\n/**\n * Configures the global audio behavior and session settings.\n *\n * This function allows you to control how your app's audio interacts with other apps,\n * background playback behavior, audio routing, and interruption handling.\n *\n * @param mode Partial audio mode configuration object. Only specified properties will be updated.\n * @returns A Promise that resolves when the audio mode has been applied.\n *\n * @example\n * ```tsx\n * import { setAudioModeAsync } from 'expo-audio';\n *\n * // Configure audio for background playback\n * await setAudioModeAsync({\n * playsInSilentMode: true,\n * shouldPlayInBackground: true,\n * interruptionModeAndroid: 'duckOthers',\n * interruptionMode: 'mixWithOthers'\n * });\n *\n * // Configure audio for recording\n * await setAudioModeAsync({\n * allowsRecording: true,\n * playsInSilentMode: false\n * });\n * ```\n */\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/**\n * Requests permission to record audio from the microphone.\n *\n * This function prompts the user for microphone access permission, which is required\n * for audio recording functionality. On iOS, this will show the system permission dialog.\n * On Android, this requests the `RECORD_AUDIO` permission.\n *\n * @returns A Promise that resolves to a `PermissionResponse` object containing the permission status.\n *\n * @example\n * ```tsx\n * import { requestRecordingPermissionsAsync } from 'expo-audio';\n *\n * const checkPermissions = async () => {\n * const { status, granted } = await requestRecordingPermissionsAsync();\n *\n * if (granted) {\n * console.log('Recording permission granted');\n * } else {\n * console.log('Recording permission denied:', status);\n * }\n * };\n * ```\n */\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\n/**\n * Checks the current status of recording permissions without requesting them.\n *\n * This function returns the current permission status for microphone access\n * without triggering a permission request dialog. Use this to check permissions\n * before deciding whether to call `requestRecordingPermissionsAsync()`.\n *\n * @returns A Promise that resolves to a `PermissionResponse` object containing the current permission status.\n *\n * @example\n * ```tsx\n * import { getRecordingPermissionsAsync, requestRecordingPermissionsAsync } from 'expo-audio';\n *\n * const ensureRecordingPermissions = async () => {\n * const { status } = await getRecordingPermissionsAsync();\n *\n * if (status !== 'granted') {\n * // Permission not granted, request it\n * const { granted } = await requestRecordingPermissionsAsync();\n * return granted;\n * }\n *\n * return true; // Already granted\n * };\n * ```\n */\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoAudio.js","sourceRoot":"","sources":["../src/ExpoAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAsB,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C,0BAA0B;YAC3D,gBAAgB,EAAE,IAAI,CAAC,uBAAuB;SAC/C,CAAC;IACR,OAAO,MAAM,WAAW,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,MAAM,WAAW,CAAC,gCAAgC,EAAE,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,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 AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n PitchCorrectionQuality,\n RecorderState,\n RecordingOptions,\n RecordingStartOptions,\n RecordingStatus,\n} from './Audio.types';\nimport {\n AUDIO_SAMPLE_UPDATE,\n PLAYBACK_STATUS_UPDATE,\n RECORDING_STATUS_UPDATE,\n} from './AudioEventKeys';\nimport AudioModule from './AudioModule';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource, resolveSourceWithDownload } from './utils/resolveSource';\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\nconst setPlaybackRate = AudioModule.AudioPlayer.prototype.setPlaybackRate;\nAudioModule.AudioPlayer.prototype.setPlaybackRate = function (\n rate: number,\n pitchCorrectionQuality?: PitchCorrectionQuality\n) {\n if (Platform.OS === 'android') {\n return setPlaybackRate.call(this, rate);\n } else {\n return setPlaybackRate.call(this, rate, pitchCorrectionQuality);\n }\n};\n\n// Audio recording prototypes should not be shimmed on tvOS, where they do not exist\nif (!Platform.isTV || Platform.OS !== 'ios') {\n const prepareToRecordAsync = AudioModule.AudioRecorder.prototype.prepareToRecordAsync;\n AudioModule.AudioRecorder.prototype.prepareToRecordAsync = function (options?: RecordingOptions) {\n const processedOptions = options ? createRecordingOptions(options) : undefined;\n return prepareToRecordAsync.call(this, processedOptions);\n };\n\n const record = AudioModule.AudioRecorder.prototype.record;\n AudioModule.AudioRecorder.prototype.record = function (options?: RecordingStartOptions) {\n return record.call(this, options);\n };\n}\n\n/**\n * Creates an `AudioPlayer` instance that automatically releases when the component unmounts.\n *\n * This hook manages the player's lifecycle and ensures it's properly disposed when no longer needed.\n * The player will start loading the audio source immediately upon creation.\n *\n * @param source The audio source to load. Can be a local asset via `require()`, a remote URL, or null for no initial source.\n * @param options Audio player configuration options.\n * @returns An `AudioPlayer` instance that's automatically managed by the component lifecycle.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer } from 'expo-audio';\n *\n * function MyComponent() {\n * const player = useAudioPlayer(require('./sound.mp3'));\n *\n * return (\n * <Button title=\"Play\" onPress={() => player.play()} />\n * );\n * }\n * ```\n *\n * @example Using downloadFirst\n * ```tsx\n * import { useAudioPlayer } from 'expo-audio';\n *\n * function MyComponent() {\n * const player = useAudioPlayer('https://example.com/audio.mp3', {\n * updateInterval: 1000,\n * downloadFirst: true,\n * });\n *\n * return (\n * <Button title=\"Play\" onPress={() => player.play()} />\n * );\n * }\n * ```\n */\nexport function useAudioPlayer(\n source: AudioSource = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { updateInterval = 500, downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.\n // If downloadFirst is false, we resolve the source here.\n // we call .replace() in the useEffect below to replace the source with the downloaded one.\n const initialSource = useMemo(() => {\n return downloadFirst ? null : resolveSource(source);\n }, [JSON.stringify(source), downloadFirst]);\n\n const player = useReleasingSharedObject(\n () => new AudioModule.AudioPlayer(initialSource, updateInterval),\n [JSON.stringify(initialSource), updateInterval]\n );\n\n // Handle async source resolution for downloadFirst\n useEffect(() => {\n if (!downloadFirst || source === null) {\n return;\n }\n\n let isCancelled = false;\n\n // We resolve the source with expo-asset and replace the player's source with the downloaded one.\n async function resolveAndReplaceSource() {\n try {\n const resolved = await resolveSourceWithDownload(source);\n\n if (\n !isCancelled &&\n resolved &&\n JSON.stringify(resolved) !== JSON.stringify(initialSource)\n ) {\n player.replace(resolved);\n }\n } catch (error) {\n if (!isCancelled) {\n console.warn('expo-audio: Failed to download source, using original:', error);\n }\n }\n }\n\n resolveAndReplaceSource();\n\n return () => {\n isCancelled = true;\n };\n }, [player, JSON.stringify(source), downloadFirst]);\n\n return player;\n}\n\n/**\n * Hook that provides real-time playback status updates for an `AudioPlayer`.\n *\n * This hook automatically subscribes to playback status changes and returns the current status.\n * The status includes information about playback state, current time, duration, loading state, and more.\n *\n * @param player The `AudioPlayer` instance to monitor.\n * @returns The current `AudioStatus` object containing playback information.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer, useAudioPlayerStatus } from 'expo-audio';\n *\n * function PlayerComponent() {\n * const player = useAudioPlayer(require('./sound.mp3'));\n * const status = useAudioPlayerStatus(player);\n *\n * return (\n * <View>\n * <Text>Playing: {status.isPlaying ? 'Yes' : 'No'}</Text>\n * <Text>Current Time: {status.currentTime}s</Text>\n * <Text>Duration: {status.duration}s</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport function useAudioPlayerStatus(player: AudioPlayer): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\n/**\n * Hook that sets up audio sampling for an `AudioPlayer` and calls a listener with audio data.\n *\n * This hook enables audio sampling on the player (if supported) and subscribes to audio sample updates.\n * Audio sampling provides real-time access to audio waveform data for visualization or analysis.\n *\n * > **Note:** Audio sampling requires `RECORD_AUDIO` permission on Android and is not supported on all platforms.\n *\n * @param player The `AudioPlayer` instance to sample audio from.\n * @param listener Function called with each audio sample containing waveform data.\n *\n * @example\n * ```tsx\n * import { useAudioPlayer, useAudioSampleListener } from 'expo-audio';\n *\n * function AudioVisualizerComponent() {\n * const player = useAudioPlayer(require('./music.mp3'));\n *\n * useAudioSampleListener(player, (sample) => {\n * // Use sample.channels array for audio visualization\n * console.log('Audio sample:', sample.channels[0].frames);\n * });\n *\n * return <AudioWaveform player={player} />;\n * }\n * ```\n */\nexport function useAudioSampleListener(player: AudioPlayer, listener: (data: AudioSample) => void) {\n useEffect(() => {\n if (!player.isAudioSamplingSupported) {\n return;\n }\n player.setAudioSamplingEnabled(true);\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => subscription.remove();\n }, [player.id]);\n}\n\n/**\n * Hook that creates an `AudioRecorder` instance for recording audio.\n *\n * This hook manages the recorder's lifecycle and ensures it's properly disposed when no longer needed.\n * The recorder is automatically prepared with the provided options and can be used to record audio.\n *\n * @param options Recording configuration options including format, quality, sample rate, etc.\n * @param statusListener Optional callback function that receives recording status updates.\n * @returns An `AudioRecorder` instance that's automatically managed by the component lifecycle.\n *\n * @example\n * ```tsx\n * import { useAudioRecorder, RecordingPresets } from 'expo-audio';\n *\n * function RecorderComponent() {\n * const recorder = useAudioRecorder(\n * RecordingPresets.HIGH_QUALITY,\n * (status) => console.log('Recording status:', status)\n * );\n *\n * const startRecording = async () => {\n * await recorder.prepareToRecordAsync();\n * recorder.record();\n * };\n *\n * return (\n * <Button title=\"Start Recording\" onPress={startRecording} />\n * );\n * }\n * ```\n */\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioRecorder {\n const platformOptions = createRecordingOptions(options);\n const recorder = useReleasingSharedObject(() => {\n return new AudioModule.AudioRecorder(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => subscription.remove();\n }, [recorder.id]);\n\n return recorder;\n}\n\n/**\n * Hook that provides real-time recording state updates for an `AudioRecorder`.\n *\n * This hook polls the recorder's status at regular intervals and returns the current recording state.\n * Use this when you need to monitor the recording status without setting up a status listener.\n *\n * @param recorder The `AudioRecorder` instance to monitor.\n * @param interval How often (in milliseconds) to poll the recorder's status. Defaults to 500ms.\n * @returns The current `RecorderState` containing recording information.\n *\n * @example\n * ```tsx\n * import { useAudioRecorder, useAudioRecorderState, RecordingPresets } from 'expo-audio';\n *\n * function RecorderStatusComponent() {\n * const recorder = useAudioRecorder(RecordingPresets.HIGH_QUALITY);\n * const state = useAudioRecorderState(recorder);\n *\n * return (\n * <View>\n * <Text>Recording: {state.isRecording ? 'Yes' : 'No'}</Text>\n * <Text>Duration: {state.currentTime}s</Text>\n * <Text>Can Record: {state.canRecord ? 'Yes' : 'No'}</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport function useAudioRecorderState(recorder: AudioRecorder, interval: number = 500) {\n const [state, setState] = useState<RecorderState>(recorder.getStatus());\n\n useEffect(() => {\n const int = setInterval(() => {\n const newState = recorder.getStatus();\n\n setState((prevState) => {\n const meteringChanged =\n (prevState.metering === undefined) !== (newState.metering === undefined) ||\n (prevState.metering !== undefined &&\n newState.metering !== undefined &&\n Math.abs(prevState.metering - newState.metering) > 0.1);\n\n if (\n prevState.canRecord !== newState.canRecord ||\n prevState.isRecording !== newState.isRecording ||\n prevState.mediaServicesDidReset !== newState.mediaServicesDidReset ||\n prevState.url !== newState.url ||\n Math.abs(prevState.durationMillis - newState.durationMillis) > 50 ||\n meteringChanged\n ) {\n return newState;\n }\n return prevState;\n });\n }, interval);\n\n return () => clearInterval(int);\n }, [recorder.id]);\n\n return state;\n}\n\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`](#useaudioplayer) hook instead.\n * > See the [Using the `AudioPlayer` directly](#using-the-audioplayer-directly) section for more details.\n * @param source The audio source to load.\n * @param options Audio player configuration options.\n */\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { updateInterval = 500, downloadFirst = false } = options;\n const initialSource = downloadFirst ? null : resolveSource(source);\n const player = new AudioModule.AudioPlayer(initialSource, updateInterval);\n\n if (downloadFirst && source) {\n resolveSourceWithDownload(source)\n .then((resolved) => {\n if (resolved) {\n player.replace(resolved);\n }\n })\n .catch((error) => {\n console.warn('expo-audio: Failed to download source, using fallback:', error);\n const fallback = resolveSource(source);\n if (fallback) {\n player.replace(fallback);\n }\n });\n }\n\n return player;\n}\n\n/**\n * Enables or disables the audio subsystem globally.\n *\n * When set to `false`, this will pause all audio playback and prevent new audio from playing.\n * This is useful for implementing app-wide audio controls or responding to system events.\n *\n * @param active Whether audio should be active (`true`) or disabled (`false`).\n * @returns A Promise that resolves when the audio state has been updated.\n *\n * @example\n * ```tsx\n * import { setIsAudioActiveAsync } from 'expo-audio';\n *\n * // Disable all audio when app goes to background\n * const handleAppStateChange = async (nextAppState) => {\n * if (nextAppState === 'background') {\n * await setIsAudioActiveAsync(false);\n * } else if (nextAppState === 'active') {\n * await setIsAudioActiveAsync(true);\n * }\n * };\n * ```\n */\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\n/**\n * Configures the global audio behavior and session settings.\n *\n * This function allows you to control how your app's audio interacts with other apps,\n * background playback behavior, audio routing, and interruption handling.\n *\n * @param mode Partial audio mode configuration object. Only specified properties will be updated.\n * @returns A Promise that resolves when the audio mode has been applied.\n *\n * @example\n * ```tsx\n * import { setAudioModeAsync } from 'expo-audio';\n *\n * // Configure audio for background playback\n * await setAudioModeAsync({\n * playsInSilentMode: true,\n * shouldPlayInBackground: true,\n * interruptionModeAndroid: 'duckOthers',\n * interruptionMode: 'mixWithOthers'\n * });\n *\n * // Configure audio for recording\n * await setAudioModeAsync({\n * allowsRecording: true,\n * playsInSilentMode: false\n * });\n * ```\n */\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/**\n * Requests permission to record audio from the microphone.\n *\n * This function prompts the user for microphone access permission, which is required\n * for audio recording functionality. On iOS, this will show the system permission dialog.\n * On Android, this requests the `RECORD_AUDIO` permission.\n *\n * @returns A Promise that resolves to a `PermissionResponse` object containing the permission status.\n *\n * @example\n * ```tsx\n * import { requestRecordingPermissionsAsync } from 'expo-audio';\n *\n * const checkPermissions = async () => {\n * const { status, granted } = await requestRecordingPermissionsAsync();\n *\n * if (granted) {\n * console.log('Recording permission granted');\n * } else {\n * console.log('Recording permission denied:', status);\n * }\n * };\n * ```\n */\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\n/**\n * Checks the current status of recording permissions without requesting them.\n *\n * This function returns the current permission status for microphone access\n * without triggering a permission request dialog. Use this to check permissions\n * before deciding whether to call `requestRecordingPermissionsAsync()`.\n *\n * @returns A Promise that resolves to a `PermissionResponse` object containing the current permission status.\n *\n * @example\n * ```tsx\n * import { getRecordingPermissionsAsync, requestRecordingPermissionsAsync } from 'expo-audio';\n *\n * const ensureRecordingPermissions = async () => {\n * const { status } = await getRecordingPermissionsAsync();\n *\n * if (status !== 'granted') {\n * // Permission not granted, request it\n * const { granted } = await requestRecordingPermissionsAsync();\n * return granted;\n * }\n *\n * return true; // Already granted\n * };\n * ```\n */\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
|
package/build/ExpoAudio.web.js
CHANGED
|
@@ -11,11 +11,11 @@ const objectUrlRegistry = new FinalizationRegistry((objectUrl) => {
|
|
|
11
11
|
URL.revokeObjectURL(objectUrl);
|
|
12
12
|
});
|
|
13
13
|
export function createAudioPlayer(source = null, options = {}) {
|
|
14
|
-
const {
|
|
14
|
+
const { downloadFirst = false } = options;
|
|
15
15
|
// If downloadFirst is true, we don't need to resolve the source, because it will be replaced once the source is downloaded.
|
|
16
16
|
// If downloadFirst is false, we resolve the source here.
|
|
17
17
|
const initialSource = downloadFirst ? null : resolveSource(source);
|
|
18
|
-
const player = new AudioModule.AudioPlayerWeb(initialSource,
|
|
18
|
+
const player = new AudioModule.AudioPlayerWeb(initialSource, options);
|
|
19
19
|
// we call .replace() on the player to replace the source with the downloaded one
|
|
20
20
|
// only relevant if downloadFirst is true and source is not null
|
|
21
21
|
if (downloadFirst && source) {
|
|
@@ -43,14 +43,14 @@ export function createAudioPlayer(source = null, options = {}) {
|
|
|
43
43
|
return player;
|
|
44
44
|
}
|
|
45
45
|
export function useAudioPlayer(source = null, options = {}) {
|
|
46
|
-
const {
|
|
46
|
+
const { downloadFirst = false } = options;
|
|
47
47
|
// If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.
|
|
48
48
|
// If downloadFirst is false, we resolve the source here.
|
|
49
49
|
// we call .replace() in the useEffect below to replace the source with the downloaded one.
|
|
50
50
|
const initialSource = useMemo(() => {
|
|
51
51
|
return downloadFirst ? null : resolveSource(source);
|
|
52
52
|
}, [JSON.stringify(source), downloadFirst]);
|
|
53
|
-
const player = useMemo(() => new AudioModule.AudioPlayerWeb(initialSource,
|
|
53
|
+
const player = useMemo(() => new AudioModule.AudioPlayerWeb(initialSource, options), [JSON.stringify(initialSource), JSON.stringify(options)]);
|
|
54
54
|
// Handle async source resolution for downloadFirst
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
if (!downloadFirst || source === null) {
|
|
@@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useEffect, useState, useMemo } from 'react';\n\nimport {\n AudioMode,\n AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n RecorderState,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\nimport {\n AUDIO_SAMPLE_UPDATE,\n PLAYBACK_STATUS_UPDATE,\n RECORDING_STATUS_UPDATE,\n} from './AudioEventKeys';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport * as AudioModule from './AudioModule.web';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource, resolveSourceWithDownload } from './utils/resolveSource';\n\n// Global registry for cleaning up object URLs when players are garbage collected\n// Since we are using blob urls, we need to clean them up when the player is garbage collected\n// this is only used for createAudioPlayer, as we have lifecycle management in useAudioPlayer\nconst objectUrlRegistry = new FinalizationRegistry((objectUrl: string) => {\n URL.revokeObjectURL(objectUrl);\n});\n\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { updateInterval = 500, downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be replaced once the source is downloaded.\n // If downloadFirst is false, we resolve the source here.\n const initialSource = downloadFirst ? null : resolveSource(source);\n const player = new AudioModule.AudioPlayerWeb(initialSource, updateInterval);\n\n // we call .replace() on the player to replace the source with the downloaded one\n // only relevant if downloadFirst is true and source is not null\n if (downloadFirst && source) {\n resolveSourceWithDownload(source)\n .then((resolved) => {\n if (resolved) {\n // Register object URL for automatic cleanup when player is garbage collected\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrlRegistry.register(player, resolved.uri);\n }\n player.replace(resolved);\n }\n })\n .catch((error) => {\n console.warn('expo-audio: Failed to download source, using fallback:', error);\n const fallback = resolveSource(source);\n if (fallback) {\n player.replace(fallback);\n }\n });\n }\n\n return player;\n}\n\nexport function useAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioModule.AudioPlayerWeb {\n const { updateInterval = 500, downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.\n // If downloadFirst is false, we resolve the source here.\n // we call .replace() in the useEffect below to replace the source with the downloaded one.\n const initialSource = useMemo(() => {\n return downloadFirst ? null : resolveSource(source);\n }, [JSON.stringify(source), downloadFirst]);\n\n const player = useMemo(\n () => new AudioModule.AudioPlayerWeb(initialSource, updateInterval),\n [JSON.stringify(initialSource), updateInterval]\n );\n\n // Handle async source resolution for downloadFirst\n useEffect(() => {\n if (!downloadFirst || source === null) {\n return;\n }\n\n let isCancelled = false;\n let objectUrl: string | null = null;\n\n // We resolve the source with expo-asset and replace the player's source with the downloaded one.\n async function resolveAndReplaceSource() {\n try {\n const resolved = await resolveSourceWithDownload(source);\n if (\n !isCancelled &&\n resolved &&\n JSON.stringify(resolved) !== JSON.stringify(initialSource)\n ) {\n // Track the object URL for cleanup\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrl = resolved.uri;\n }\n player.replace(resolved);\n }\n } catch (error) {\n if (!isCancelled) {\n console.warn('expo-audio: Failed to download source, using original:', error);\n }\n }\n }\n\n resolveAndReplaceSource();\n\n return () => {\n isCancelled = true;\n player.remove();\n // Revoke the object URL created by this hook instance\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n }\n };\n }, [player, JSON.stringify(source), downloadFirst]);\n\n return player;\n}\n\nexport function useAudioPlayerStatus(player: AudioModule.AudioPlayerWeb): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\nexport function useAudioSampleListener(\n player: AudioModule.AudioPlayerWeb,\n listener: (data: AudioSample) => void\n) {\n player.setAudioSamplingEnabled(true);\n useEffect(() => {\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => {\n player.setAudioSamplingEnabled(false);\n subscription.remove();\n };\n }, [player.id]);\n}\n\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioModule.AudioRecorderWeb {\n const platformOptions = createRecordingOptions(options);\n const recorder = useMemo(() => {\n return new AudioModule.AudioRecorderWeb(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => {\n recorder.clearTimeouts();\n subscription.remove();\n };\n }, [recorder.id]);\n\n return recorder;\n}\n\nexport function useAudioRecorderState(recorder: AudioRecorder, interval: number = 500) {\n const [state, setState] = useState<RecorderState>(recorder.getStatus());\n\n useEffect(() => {\n const id = setInterval(() => {\n setState(recorder.getStatus());\n }, interval);\n\n return () => clearInterval(id);\n }, [recorder.id]);\n\n return state;\n}\n\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\nexport async function setAudioModeAsync(mode: AudioMode): Promise<void> {\n return await AudioModule.setAudioModeAsync(mode);\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoAudio.web.js","sourceRoot":"","sources":["../src/ExpoAudio.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAWrD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAA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AAE,GAAG,WAAW,CAAC,GAAG,EAAE;YAC1B,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QACjC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAEb,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAe;IACzD,OAAO,MAAM,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAe;IACrD,OAAO,MAAM,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,MAAM,WAAW,CAAC,gCAAgC,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,OAAO,MAAM,WAAW,CAAC,4BAA4B,EAAE,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { useEvent } from 'expo';\nimport { PermissionResponse } from 'expo-modules-core';\nimport { useEffect, useState, useMemo } from 'react';\n\nimport {\n AudioMode,\n AudioPlayerOptions,\n AudioSource,\n AudioStatus,\n RecorderState,\n RecordingOptions,\n RecordingStatus,\n} from './Audio.types';\nimport {\n AUDIO_SAMPLE_UPDATE,\n PLAYBACK_STATUS_UPDATE,\n RECORDING_STATUS_UPDATE,\n} from './AudioEventKeys';\nimport { AudioPlayer, AudioRecorder, AudioSample } from './AudioModule.types';\nimport * as AudioModule from './AudioModule.web';\nimport { createRecordingOptions } from './utils/options';\nimport { resolveSource, resolveSourceWithDownload } from './utils/resolveSource';\n\n// Global registry for cleaning up object URLs when players are garbage collected\n// Since we are using blob urls, we need to clean them up when the player is garbage collected\n// this is only used for createAudioPlayer, as we have lifecycle management in useAudioPlayer\nconst objectUrlRegistry = new FinalizationRegistry((objectUrl: string) => {\n URL.revokeObjectURL(objectUrl);\n});\n\nexport function createAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioPlayer {\n const { downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be replaced once the source is downloaded.\n // If downloadFirst is false, we resolve the source here.\n const initialSource = downloadFirst ? null : resolveSource(source);\n const player = new AudioModule.AudioPlayerWeb(initialSource, options);\n\n // we call .replace() on the player to replace the source with the downloaded one\n // only relevant if downloadFirst is true and source is not null\n if (downloadFirst && source) {\n resolveSourceWithDownload(source)\n .then((resolved) => {\n if (resolved) {\n // Register object URL for automatic cleanup when player is garbage collected\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrlRegistry.register(player, resolved.uri);\n }\n player.replace(resolved);\n }\n })\n .catch((error) => {\n console.warn('expo-audio: Failed to download source, using fallback:', error);\n const fallback = resolveSource(source);\n if (fallback) {\n player.replace(fallback);\n }\n });\n }\n\n return player;\n}\n\nexport function useAudioPlayer(\n source: AudioSource | string | number | null = null,\n options: AudioPlayerOptions = {}\n): AudioModule.AudioPlayerWeb {\n const { downloadFirst = false } = options;\n\n // If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.\n // If downloadFirst is false, we resolve the source here.\n // we call .replace() in the useEffect below to replace the source with the downloaded one.\n const initialSource = useMemo(() => {\n return downloadFirst ? null : resolveSource(source);\n }, [JSON.stringify(source), downloadFirst]);\n\n const player = useMemo(\n () => new AudioModule.AudioPlayerWeb(initialSource, options),\n [JSON.stringify(initialSource), JSON.stringify(options)]\n );\n\n // Handle async source resolution for downloadFirst\n useEffect(() => {\n if (!downloadFirst || source === null) {\n return;\n }\n\n let isCancelled = false;\n let objectUrl: string | null = null;\n\n // We resolve the source with expo-asset and replace the player's source with the downloaded one.\n async function resolveAndReplaceSource() {\n try {\n const resolved = await resolveSourceWithDownload(source);\n if (\n !isCancelled &&\n resolved &&\n JSON.stringify(resolved) !== JSON.stringify(initialSource)\n ) {\n // Track the object URL for cleanup\n if (\n resolved &&\n typeof resolved === 'object' &&\n resolved.uri &&\n resolved.uri.startsWith('blob:')\n ) {\n objectUrl = resolved.uri;\n }\n player.replace(resolved);\n }\n } catch (error) {\n if (!isCancelled) {\n console.warn('expo-audio: Failed to download source, using original:', error);\n }\n }\n }\n\n resolveAndReplaceSource();\n\n return () => {\n isCancelled = true;\n player.remove();\n // Revoke the object URL created by this hook instance\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n }\n };\n }, [player, JSON.stringify(source), downloadFirst]);\n\n return player;\n}\n\nexport function useAudioPlayerStatus(player: AudioModule.AudioPlayerWeb): AudioStatus {\n const currentStatus = useMemo(() => player.currentStatus, [player.id]);\n return useEvent(player, PLAYBACK_STATUS_UPDATE, currentStatus);\n}\n\nexport function useAudioSampleListener(\n player: AudioModule.AudioPlayerWeb,\n listener: (data: AudioSample) => void\n) {\n player.setAudioSamplingEnabled(true);\n useEffect(() => {\n const subscription = player.addListener(AUDIO_SAMPLE_UPDATE, listener);\n return () => {\n player.setAudioSamplingEnabled(false);\n subscription.remove();\n };\n }, [player.id]);\n}\n\nexport function useAudioRecorder(\n options: RecordingOptions,\n statusListener?: (status: RecordingStatus) => void\n): AudioModule.AudioRecorderWeb {\n const platformOptions = createRecordingOptions(options);\n const recorder = useMemo(() => {\n return new AudioModule.AudioRecorderWeb(platformOptions);\n }, [JSON.stringify(platformOptions)]);\n\n useEffect(() => {\n const subscription = recorder.addListener(RECORDING_STATUS_UPDATE, (status) => {\n statusListener?.(status);\n });\n return () => {\n recorder.clearTimeouts();\n subscription.remove();\n };\n }, [recorder.id]);\n\n return recorder;\n}\n\nexport function useAudioRecorderState(recorder: AudioRecorder, interval: number = 500) {\n const [state, setState] = useState<RecorderState>(recorder.getStatus());\n\n useEffect(() => {\n const id = setInterval(() => {\n setState(recorder.getStatus());\n }, interval);\n\n return () => clearInterval(id);\n }, [recorder.id]);\n\n return state;\n}\n\nexport async function setIsAudioActiveAsync(active: boolean): Promise<void> {\n return await AudioModule.setIsAudioActiveAsync(active);\n}\n\nexport async function setAudioModeAsync(mode: AudioMode): Promise<void> {\n return await AudioModule.setAudioModeAsync(mode);\n}\n\nexport async function requestRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.requestRecordingPermissionsAsync();\n}\n\nexport async function getRecordingPermissionsAsync(): Promise<PermissionResponse> {\n return await AudioModule.getRecordingPermissionsAsync();\n}\n\nexport { AudioModule };\n"]}
|
package/expo-module.config.json
CHANGED
package/ios/AudioModule.swift
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "expo.modules.audio",
|
|
5
5
|
"module": "expo.modules.audio",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.1",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.audio-1.0.
|
|
28
|
-
"url": "expo.modules.audio-1.0.
|
|
27
|
+
"name": "expo.modules.audio-1.0.1.aar",
|
|
28
|
+
"url": "expo.modules.audio-1.0.1.aar",
|
|
29
29
|
"size": 207200,
|
|
30
30
|
"sha512": "34b6873d9e5a62adefff626c337114ec2a80c52589a7b9cd9649d401e6a92fee1b1e0d78ebc330a534d091e6b9cdd6fed66f4031c1068934ed01cb2afe79d72d",
|
|
31
31
|
"sha256": "b785d3122b0d76aa8680d6c8971a087c2ba4f44ff746cb482f319fe930366957",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
],
|
|
96
96
|
"files": [
|
|
97
97
|
{
|
|
98
|
-
"name": "expo.modules.audio-1.0.
|
|
99
|
-
"url": "expo.modules.audio-1.0.
|
|
98
|
+
"name": "expo.modules.audio-1.0.1.aar",
|
|
99
|
+
"url": "expo.modules.audio-1.0.1.aar",
|
|
100
100
|
"size": 207200,
|
|
101
101
|
"sha512": "34b6873d9e5a62adefff626c337114ec2a80c52589a7b9cd9649d401e6a92fee1b1e0d78ebc330a534d091e6b9cdd6fed66f4031c1068934ed01cb2afe79d72d",
|
|
102
102
|
"sha256": "b785d3122b0d76aa8680d6c8971a087c2ba4f44ff746cb482f319fe930366957",
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
},
|
|
116
116
|
"files": [
|
|
117
117
|
{
|
|
118
|
-
"name": "expo.modules.audio-1.0.
|
|
119
|
-
"url": "expo.modules.audio-1.0.
|
|
118
|
+
"name": "expo.modules.audio-1.0.1-sources.jar",
|
|
119
|
+
"url": "expo.modules.audio-1.0.1-sources.jar",
|
|
120
120
|
"size": 12938,
|
|
121
121
|
"sha512": "8463d4e34a5cf3782a3d0a4a8c6d9e59288c945d03b38c235c7aca22d68ac2b0dd7b76cccc6cf7b16edaa4c67e4a3bda7ce8e8cdd032c5f790ba7e4cba94c97c",
|
|
122
122
|
"sha256": "b6c787e4a03dc0d84ad47540f11cefb44c062517274b0c55315db18e56339a9f",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b9a49b313cdc784b014d24687329d08b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
372303cd4908d805e51ebfa086846207ec178463
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fe53ffc1cc61ce4385c05658d1cc6b8fe12cb3ee7c93f25467d110b8c8ab093e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
786c091edbf58a99046644f95e1aa91ee2afdc011c23e3bca57a98a7dc672958fb53c03da7e094f7c939476b44b68a4dca16991727f9f4266a01afd803b766c2
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>expo.modules.audio</groupId>
|
|
11
11
|
<artifactId>expo.modules.audio</artifactId>
|
|
12
|
-
<version>1.0.
|
|
12
|
+
<version>1.0.1</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
|
+
838d3f638020de945db6a297eae1011c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
003cadb9c3ce01e8c4f8153d93bbadf4d37ed672
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
63853814c257d49bdb3d9c17fac2cf7846b885ea5c918f1783d3196cc3e8d3b2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bde013e945c656095696caa1365c42de54cf0fc6b54f52017082deb6be94adf5d20a733cdce23880f9f03c3361a52bb95101d864216bef3afd1b885b8fd27a37
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>expo.modules.audio</groupId>
|
|
4
4
|
<artifactId>expo.modules.audio</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>1.0.
|
|
7
|
-
<release>1.0.
|
|
6
|
+
<latest>1.0.1</latest>
|
|
7
|
+
<release>1.0.1</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>1.0.
|
|
9
|
+
<version>1.0.1</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250815180457</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1af69c5c1bb40234b11070ba11548b94
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
b841779e315ae310d8eb0bbf3391d850ac292864
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e77be3cdf156ad041f2669b2ddbf29b18422b1c4290d4b7c979e8ae47e6c37a7
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
124e32fdd2a9604902f3ef5a918276bdd688fd74779c59a03387584e6723b2b539f2301f3d7971bb18689ae518d44cb815737941e1ec018edc990f541978761b
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-audio",
|
|
3
3
|
"title": "Expo Audio",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
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": "^5.0.
|
|
36
|
+
"expo-module-scripts": "^5.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"expo": "*",
|
|
40
40
|
"react": "*",
|
|
41
41
|
"react-native": "*"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "2f7f90d0736af48cb542ccbc8addb836e330693a"
|
|
44
44
|
}
|
package/src/Audio.types.ts
CHANGED
|
@@ -59,6 +59,17 @@ export type AudioPlayerOptions = {
|
|
|
59
59
|
* @platform android
|
|
60
60
|
*/
|
|
61
61
|
downloadFirst?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Determines the [cross origin policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin) used by the underlying native view on web.
|
|
64
|
+
* If `undefined` (default), does not use CORS at all. If set to `'anonymous'`, the audio will be loaded with CORS enabled.
|
|
65
|
+
* Note that some audio may not play if CORS is enabled, depending on the CDN settings.
|
|
66
|
+
* If you encounter issues, consider adjusting the `crossOrigin` property.
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
* @platform web
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
72
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
/**
|
package/src/AudioModule.web.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PermissionResponse, PermissionStatus } from 'expo-modules-core';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
AudioMode,
|
|
5
|
+
AudioPlayerOptions,
|
|
5
6
|
AudioSource,
|
|
6
7
|
AudioStatus,
|
|
7
8
|
PitchCorrectionQuality,
|
|
@@ -103,10 +104,12 @@ export class AudioPlayerWeb
|
|
|
103
104
|
extends globalThis.expo.SharedObject<AudioEvents>
|
|
104
105
|
implements AudioPlayer
|
|
105
106
|
{
|
|
106
|
-
constructor(source: AudioSource,
|
|
107
|
+
constructor(source: AudioSource, options: AudioPlayerOptions = {}) {
|
|
107
108
|
super();
|
|
109
|
+
const { updateInterval = 500, crossOrigin } = options;
|
|
108
110
|
this.src = source;
|
|
109
|
-
this.interval = Math.max(
|
|
111
|
+
this.interval = Math.max(updateInterval, 1);
|
|
112
|
+
this.crossOrigin = crossOrigin;
|
|
110
113
|
this.media = this._createMediaElement();
|
|
111
114
|
}
|
|
112
115
|
|
|
@@ -120,6 +123,7 @@ export class AudioPlayerWeb
|
|
|
120
123
|
private interval = 500;
|
|
121
124
|
private isPlaying = false;
|
|
122
125
|
private loaded = false;
|
|
126
|
+
private crossOrigin?: 'anonymous' | 'use-credentials';
|
|
123
127
|
|
|
124
128
|
get playing(): boolean {
|
|
125
129
|
return this.isPlaying;
|
|
@@ -233,7 +237,9 @@ export class AudioPlayerWeb
|
|
|
233
237
|
_createMediaElement() {
|
|
234
238
|
const newSource = getSourceUri(this.src);
|
|
235
239
|
const media = new Audio(newSource);
|
|
236
|
-
|
|
240
|
+
if (this.crossOrigin !== undefined) {
|
|
241
|
+
media.crossOrigin = this.crossOrigin;
|
|
242
|
+
}
|
|
237
243
|
|
|
238
244
|
let lastEmitTime = 0;
|
|
239
245
|
const intervalSec = this.interval / 1000;
|
package/src/ExpoAudio.ts
CHANGED
|
@@ -42,16 +42,19 @@ AudioModule.AudioPlayer.prototype.setPlaybackRate = function (
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
// Audio recording prototypes should not be shimmed on tvOS, where they do not exist
|
|
46
|
+
if (!Platform.isTV || Platform.OS !== 'ios') {
|
|
47
|
+
const prepareToRecordAsync = AudioModule.AudioRecorder.prototype.prepareToRecordAsync;
|
|
48
|
+
AudioModule.AudioRecorder.prototype.prepareToRecordAsync = function (options?: RecordingOptions) {
|
|
49
|
+
const processedOptions = options ? createRecordingOptions(options) : undefined;
|
|
50
|
+
return prepareToRecordAsync.call(this, processedOptions);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const record = AudioModule.AudioRecorder.prototype.record;
|
|
54
|
+
AudioModule.AudioRecorder.prototype.record = function (options?: RecordingStartOptions) {
|
|
55
|
+
return record.call(this, options);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Creates an `AudioPlayer` instance that automatically releases when the component unmounts.
|
package/src/ExpoAudio.web.ts
CHANGED
|
@@ -32,12 +32,12 @@ export function createAudioPlayer(
|
|
|
32
32
|
source: AudioSource | string | number | null = null,
|
|
33
33
|
options: AudioPlayerOptions = {}
|
|
34
34
|
): AudioPlayer {
|
|
35
|
-
const {
|
|
35
|
+
const { downloadFirst = false } = options;
|
|
36
36
|
|
|
37
37
|
// If downloadFirst is true, we don't need to resolve the source, because it will be replaced once the source is downloaded.
|
|
38
38
|
// If downloadFirst is false, we resolve the source here.
|
|
39
39
|
const initialSource = downloadFirst ? null : resolveSource(source);
|
|
40
|
-
const player = new AudioModule.AudioPlayerWeb(initialSource,
|
|
40
|
+
const player = new AudioModule.AudioPlayerWeb(initialSource, options);
|
|
41
41
|
|
|
42
42
|
// we call .replace() on the player to replace the source with the downloaded one
|
|
43
43
|
// only relevant if downloadFirst is true and source is not null
|
|
@@ -73,7 +73,7 @@ export function useAudioPlayer(
|
|
|
73
73
|
source: AudioSource | string | number | null = null,
|
|
74
74
|
options: AudioPlayerOptions = {}
|
|
75
75
|
): AudioModule.AudioPlayerWeb {
|
|
76
|
-
const {
|
|
76
|
+
const { downloadFirst = false } = options;
|
|
77
77
|
|
|
78
78
|
// If downloadFirst is true, we don't need to resolve the source, because it will be resolved in the useEffect below.
|
|
79
79
|
// If downloadFirst is false, we resolve the source here.
|
|
@@ -83,8 +83,8 @@ export function useAudioPlayer(
|
|
|
83
83
|
}, [JSON.stringify(source), downloadFirst]);
|
|
84
84
|
|
|
85
85
|
const player = useMemo(
|
|
86
|
-
() => new AudioModule.AudioPlayerWeb(initialSource,
|
|
87
|
-
[JSON.stringify(initialSource),
|
|
86
|
+
() => new AudioModule.AudioPlayerWeb(initialSource, options),
|
|
87
|
+
[JSON.stringify(initialSource), JSON.stringify(options)]
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
// Handle async source resolution for downloadFirst
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f945e2c50d9e4a0442e0eda00549417a
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0730a0b37d3a719a4a0dd2e2cc65755fb6d6423c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
c335a5574e36af863771d78c18b35c14bcd704cc2de9dfbdf6d158d176ed9d91
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
36246ec740a8457b37b0371a33bb2e4a900253d6d61954ba9976f75df15454c9c864ae7f86affadcac29ae45dda9f4bbac711b88b9e151576fa6c08d4103e2a6
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4afb6f9a4ba5c549276e9a0afe4ac399
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d89c81970e5312110a248ca9da5505acb2fde68b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
172079cded223057c87c0bb5b586e02d667ae279a684c24c954701bb3ad0747d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
a92e7770db27cc301c82879620e3a25322c0d39fbf918c150a696050e5222a10bebec055f143ff62ce1b8a8601334663ddcc7e23304f9355e1e8e473058dcb85
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|