@symbiote-native/audio 0.1.0
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/LICENSE +21 -0
- package/README.md +249 -0
- package/build/angular/index.d.ts +1 -0
- package/build/angular/index.js +4 -0
- package/build/core/audio-module.d.ts +26 -0
- package/build/core/audio-module.js +64 -0
- package/build/core/audio-player.d.ts +13 -0
- package/build/core/audio-player.js +31 -0
- package/build/core/audio-playlist.d.ts +8 -0
- package/build/core/audio-playlist.js +14 -0
- package/build/core/audio-recorder.d.ts +5 -0
- package/build/core/audio-recorder.js +40 -0
- package/build/core/audio-stream.d.ts +13 -0
- package/build/core/audio-stream.js +16 -0
- package/build/core/index.d.ts +9 -0
- package/build/core/index.js +8 -0
- package/build/core/native-module.d.ts +134 -0
- package/build/core/native-module.js +2 -0
- package/build/core/recording-presets.d.ts +50 -0
- package/build/core/recording-presets.js +94 -0
- package/build/core/resolve-source.d.ts +10 -0
- package/build/core/resolve-source.js +31 -0
- package/build/core/types.d.ts +218 -0
- package/build/core/types.js +8 -0
- package/build-ngc/angular/index.d.ts +1 -0
- package/build-ngc/angular/index.js +5 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/core/audio-module.d.ts +26 -0
- package/build-ngc/core/audio-module.js +65 -0
- package/build-ngc/core/audio-module.js.map +1 -0
- package/build-ngc/core/audio-player.d.ts +13 -0
- package/build-ngc/core/audio-player.js +32 -0
- package/build-ngc/core/audio-player.js.map +1 -0
- package/build-ngc/core/audio-playlist.d.ts +8 -0
- package/build-ngc/core/audio-playlist.js +15 -0
- package/build-ngc/core/audio-playlist.js.map +1 -0
- package/build-ngc/core/audio-recorder.d.ts +5 -0
- package/build-ngc/core/audio-recorder.js +41 -0
- package/build-ngc/core/audio-recorder.js.map +1 -0
- package/build-ngc/core/audio-stream.d.ts +13 -0
- package/build-ngc/core/audio-stream.js +17 -0
- package/build-ngc/core/audio-stream.js.map +1 -0
- package/build-ngc/core/index.d.ts +9 -0
- package/build-ngc/core/index.js +9 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/native-module.d.ts +134 -0
- package/build-ngc/core/native-module.js +3 -0
- package/build-ngc/core/native-module.js.map +1 -0
- package/build-ngc/core/recording-presets.d.ts +50 -0
- package/build-ngc/core/recording-presets.js +95 -0
- package/build-ngc/core/recording-presets.js.map +1 -0
- package/build-ngc/core/resolve-source.d.ts +10 -0
- package/build-ngc/core/resolve-source.js +32 -0
- package/build-ngc/core/resolve-source.js.map +1 -0
- package/build-ngc/core/types.d.ts +218 -0
- package/build-ngc/core/types.js +9 -0
- package/build-ngc/core/types.js.map +1 -0
- package/native-link.json +47 -0
- package/package.json +150 -0
- package/src/angular/index.ts +4 -0
- package/src/core/audio-module.ts +82 -0
- package/src/core/audio-player.ts +53 -0
- package/src/core/audio-playlist.ts +20 -0
- package/src/core/audio-recorder.ts +46 -0
- package/src/core/audio-stream.ts +22 -0
- package/src/core/index.ts +62 -0
- package/src/core/native-module.ts +181 -0
- package/src/core/recording-presets.ts +99 -0
- package/src/core/resolve-source.ts +41 -0
- package/src/core/types.ts +282 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expoAudio } from './native-module';
|
|
2
|
+
import type { IAudioPlayerOptions, IAudioSource, IPitchCorrectionQuality } from './types';
|
|
3
|
+
export declare class AudioPlayer extends expoAudio.AudioPlayer {
|
|
4
|
+
replace(source: IAudioSource): void;
|
|
5
|
+
setPlaybackRate(rate: number, pitchCorrectionQuality?: IPitchCorrectionQuality): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates an `AudioPlayer` that does not release automatically — call `.remove()` when done with
|
|
9
|
+
* it. There is no lifecycle wrapper here (framework-agnostic core, see the package README); each
|
|
10
|
+
* adapter's own hook/composable/service is responsible for releasing it on unmount, mirroring
|
|
11
|
+
* upstream's `useReleasingSharedObject`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAudioPlayer(source?: IAudioSource, options?: IAudioPlayerOptions): AudioPlayer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Platform } from 'expo-modules-core';
|
|
2
|
+
import { expoAudio } from './native-module';
|
|
3
|
+
import { resolveSource } from './resolve-source';
|
|
4
|
+
// Upstream shims these two methods onto `AudioModule.AudioPlayer.prototype` at module load
|
|
5
|
+
// (ExpoAudio.ts). We do the equivalent by subclassing instead of monkey-patching the native
|
|
6
|
+
// class's prototype — same shape packages/media-library/src/next/asset.ts uses for its own
|
|
7
|
+
// platform-conditional overrides.
|
|
8
|
+
export class AudioPlayer extends expoAudio.AudioPlayer {
|
|
9
|
+
replace(source) {
|
|
10
|
+
super.replace(resolveSource(source));
|
|
11
|
+
}
|
|
12
|
+
setPlaybackRate(rate, pitchCorrectionQuality) {
|
|
13
|
+
if (Platform.OS === 'android') {
|
|
14
|
+
super.setPlaybackRate(rate);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
super.setPlaybackRate(rate, pitchCorrectionQuality);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates an `AudioPlayer` that does not release automatically — call `.remove()` when done with
|
|
23
|
+
* it. There is no lifecycle wrapper here (framework-agnostic core, see the package README); each
|
|
24
|
+
* adapter's own hook/composable/service is responsible for releasing it on unmount, mirroring
|
|
25
|
+
* upstream's `useReleasingSharedObject`.
|
|
26
|
+
*/
|
|
27
|
+
export function createAudioPlayer(source = null, options = {}) {
|
|
28
|
+
const { updateInterval = 500, keepAudioSessionActive = false, preferredForwardBufferDuration = 0, } = options;
|
|
29
|
+
const resolvedSource = resolveSource(source);
|
|
30
|
+
return new AudioPlayer(resolvedSource, updateInterval, keepAudioSessionActive, preferredForwardBufferDuration);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=audio-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-player.js","sourceRoot":"","sources":["../../src/core/audio-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOjD,2FAA2F;AAC3F,4FAA4F;AAC5F,2FAA2F;AAC3F,kCAAkC;AAClC,MAAM,OAAO,WAAY,SAAQ,SAAS,CAAC,WAAW;IAC3C,OAAO,CAAC,MAAoB;QACnC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,CAAC;IAEQ,eAAe,CACtB,IAAY,EACZ,sBAAgD;QAEhD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAuB,IAAI,EAC3B,UAA+B,EAAE;IAEjC,MAAM,EACJ,cAAc,GAAG,GAAG,EACpB,sBAAsB,GAAG,KAAK,EAC9B,8BAA8B,GAAG,CAAC,GACnC,GAAG,OAAO,CAAC;IACZ,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,WAAW,CACpB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,8BAA8B,CAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IAudioPlaylistOptions } from './types';
|
|
2
|
+
export declare const AudioPlaylist: typeof import("./native-module").NativeAudioPlaylist;
|
|
3
|
+
export type AudioPlaylist = InstanceType<typeof AudioPlaylist>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates an `AudioPlaylist` that does not release automatically — call `.destroy()` when done
|
|
6
|
+
* with it. See `createAudioPlayer`'s doc comment for the same lifecycle note.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAudioPlaylist(options?: IAudioPlaylistOptions): AudioPlaylist;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expoAudio } from './native-module';
|
|
2
|
+
import { resolveSources } from './resolve-source';
|
|
3
|
+
// No prototype shim on `AudioPlaylist` upstream (unlike `AudioPlayer`/`AudioRecorder`) — its
|
|
4
|
+
// `add`/`insert` take an already-resolved source, so a plain re-export is faithful to upstream.
|
|
5
|
+
export const AudioPlaylist = expoAudio.AudioPlaylist;
|
|
6
|
+
/**
|
|
7
|
+
* Creates an `AudioPlaylist` that does not release automatically — call `.destroy()` when done
|
|
8
|
+
* with it. See `createAudioPlayer`'s doc comment for the same lifecycle note.
|
|
9
|
+
*/
|
|
10
|
+
export function createAudioPlaylist(options = {}) {
|
|
11
|
+
const { sources = [], updateInterval = 500, loop = 'none' } = options;
|
|
12
|
+
const resolvedSources = resolveSources(sources);
|
|
13
|
+
return new AudioPlaylist(resolvedSources, updateInterval, loop);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=audio-playlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-playlist.js","sourceRoot":"","sources":["../../src/core/audio-playlist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,6FAA6F;AAC7F,gGAAgG;AAChG,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;AAGrD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAiC,EAAE;IAEnC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,GAAG,EAAE,IAAI,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;IACtE,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,IAAI,aAAa,CAAC,eAAe,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Platform } from 'expo-modules-core';
|
|
2
|
+
import { expoAudio } from './native-module';
|
|
3
|
+
/**
|
|
4
|
+
* Fills in the per-platform recording config from `RecordingOptions`'s common fields, ported
|
|
5
|
+
* from upstream's `utils/options.ts`. Only the fields the current platform's native recorder
|
|
6
|
+
* reads are kept, with `options.ios`/`options.android`/`options.web` spread on top so an
|
|
7
|
+
* explicit per-platform override always wins.
|
|
8
|
+
*/
|
|
9
|
+
function createRecordingOptions(options) {
|
|
10
|
+
const commonOptions = {
|
|
11
|
+
extension: options.extension,
|
|
12
|
+
sampleRate: options.sampleRate,
|
|
13
|
+
numberOfChannels: options.numberOfChannels,
|
|
14
|
+
bitRate: options.bitRate,
|
|
15
|
+
isMeteringEnabled: options.isMeteringEnabled ?? false,
|
|
16
|
+
};
|
|
17
|
+
if (Platform.OS === 'ios') {
|
|
18
|
+
return { ...commonOptions, directory: options.directory, ...options.ios };
|
|
19
|
+
}
|
|
20
|
+
if (Platform.OS === 'android') {
|
|
21
|
+
return {
|
|
22
|
+
...commonOptions,
|
|
23
|
+
directory: options.directory,
|
|
24
|
+
...options.android,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { ...commonOptions, ...options.web };
|
|
28
|
+
}
|
|
29
|
+
// Upstream shims `prepareToRecordAsync` onto `AudioModule.AudioRecorder.prototype` at module
|
|
30
|
+
// load, EXCEPT on tvOS (recording prototypes "should not be shimmed on tvOS, where they do not
|
|
31
|
+
// exist" — ExpoAudio.ts). tvOS is not a target platform of this project (root CLAUDE.md: iOS +
|
|
32
|
+
// Android only), so that branch is dropped — the options are always processed.
|
|
33
|
+
export class AudioRecorder extends expoAudio.AudioRecorder {
|
|
34
|
+
prepareToRecordAsync(options) {
|
|
35
|
+
const processedOptions = options
|
|
36
|
+
? createRecordingOptions(options)
|
|
37
|
+
: undefined;
|
|
38
|
+
return super.prepareToRecordAsync(processedOptions);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=audio-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-recorder.js","sourceRoot":"","sources":["../../src/core/audio-recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,OAA0B;IACxD,MAAM,aAAa,GAAG;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,KAAK;KACtD,CAAC;IAEF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,EAAE,GAAG,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5E,CAAC;IACD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO;YACL,GAAG,aAAa;YAChB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,GAAG,OAAO,CAAC,OAAO;SACnB,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC9C,CAAC;AAED,6FAA6F;AAC7F,+FAA+F;AAC/F,+FAA+F;AAC/F,+EAA+E;AAC/E,MAAM,OAAO,aAAc,SAAQ,SAAS,CAAC,aAAa;IAC/C,oBAAoB,CAC3B,OAAoC;QAEpC,MAAM,gBAAgB,GAAG,OAAO;YAC9B,CAAC,CAAC,sBAAsB,CAAC,OAA4B,CAAC;YACtD,CAAC,CAAC,SAAS,CAAC;QACd,OAAO,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IAudioStreamOptions } from './types';
|
|
2
|
+
export declare const AudioStream: typeof import("./native-module").NativeAudioStream;
|
|
3
|
+
export type AudioStream = InstanceType<typeof AudioStream>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a native `AudioStream` for real-time PCM microphone capture. Call `.start()` to
|
|
6
|
+
* begin and `.stop()` to end; requires microphone permission — see
|
|
7
|
+
* `requestRecordingPermissionsAsync`. Upstream only exposes this via the `useAudioStream` hook
|
|
8
|
+
* (React-only, see the package README); this factory is the framework-agnostic equivalent — the
|
|
9
|
+
* hook itself just applies these same defaults and wires `addListener` for
|
|
10
|
+
* `AUDIO_STREAM_STATUS`/`AUDIO_STREAM_BUFFER` on top, which each adapter's own lifecycle wrapper
|
|
11
|
+
* is responsible for.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAudioStream(options?: IAudioStreamOptions): AudioStream;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { expoAudio } from './native-module';
|
|
2
|
+
// Plain re-export — upstream has no prototype shim for `AudioStream` either.
|
|
3
|
+
export const AudioStream = expoAudio.AudioStream;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a native `AudioStream` for real-time PCM microphone capture. Call `.start()` to
|
|
6
|
+
* begin and `.stop()` to end; requires microphone permission — see
|
|
7
|
+
* `requestRecordingPermissionsAsync`. Upstream only exposes this via the `useAudioStream` hook
|
|
8
|
+
* (React-only, see the package README); this factory is the framework-agnostic equivalent — the
|
|
9
|
+
* hook itself just applies these same defaults and wires `addListener` for
|
|
10
|
+
* `AUDIO_STREAM_STATUS`/`AUDIO_STREAM_BUFFER` on top, which each adapter's own lifecycle wrapper
|
|
11
|
+
* is responsible for.
|
|
12
|
+
*/
|
|
13
|
+
export function createAudioStream(options = {}) {
|
|
14
|
+
const { sampleRate = 48000, channels = 1, encoding = 'float32' } = options;
|
|
15
|
+
return new AudioStream({ sampleRate, channels, encoding });
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=audio-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-stream.js","sourceRoot":"","sources":["../../src/core/audio-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;AAGjD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA+B,EAAE;IAEjC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC;IAC3E,OAAO,IAAI,WAAW,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { AudioPlayer, createAudioPlayer } from './audio-player';
|
|
2
|
+
export { AudioRecorder } from './audio-recorder';
|
|
3
|
+
export { AudioPlaylist, createAudioPlaylist } from './audio-playlist';
|
|
4
|
+
export { AudioStream, createAudioStream } from './audio-stream';
|
|
5
|
+
export { setIsAudioActiveAsync, setAudioModeAsync, requestRecordingPermissionsAsync, requestNotificationPermissionsAsync, getRecordingPermissionsAsync, preload, clearPreloadedSource, clearAllPreloadedSources, getPreloadedSources, } from './audio-module';
|
|
6
|
+
export { resolveSource, resolveSources } from './resolve-source';
|
|
7
|
+
export { RecordingPresets, IOSOutputFormat, AudioQuality, } from './recording-presets';
|
|
8
|
+
export { PLAYBACK_STATUS_UPDATE, AUDIO_SAMPLE_UPDATE, RECORDING_STATUS_UPDATE, PLAYLIST_STATUS_UPDATE, TRACK_CHANGED, AUDIO_STREAM_BUFFER, AUDIO_STREAM_STATUS, } from './types';
|
|
9
|
+
export type { IAudioSource, IAudioSourceInfo, IAudioPlayerOptions, IPreloadOptions, IRecordingInput, IPitchCorrectionQuality, IAudioStatus, IRecordingStatus, IRecorderState, IAndroidOutputFormat, IAndroidAudioEncoder, IRecordingStartOptions, IRecordingDirectory, IRecordingOptions, IRecordingOptionsWeb, IRecordingOptionsIos, IRecordingOptionsAndroid, IRecordingSource, IAudioMode, IInterruptionMode, IAudioMetadata, IAudioPlaylistLoopMode, IAudioPlaylistOptions, IAudioPlaylistStatus, IAudioLockScreenOptions, IAudioSample, IAudioStreamEncoding, IAudioStreamOptions, IAudioStreamBuffer, IAudioStreamStatus, } from './types';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { AudioPlayer, createAudioPlayer } from './audio-player';
|
|
2
|
+
export { AudioRecorder } from './audio-recorder';
|
|
3
|
+
export { AudioPlaylist, createAudioPlaylist } from './audio-playlist';
|
|
4
|
+
export { AudioStream, createAudioStream } from './audio-stream';
|
|
5
|
+
export { setIsAudioActiveAsync, setAudioModeAsync, requestRecordingPermissionsAsync, requestNotificationPermissionsAsync, getRecordingPermissionsAsync, preload, clearPreloadedSource, clearAllPreloadedSources, getPreloadedSources, } from './audio-module';
|
|
6
|
+
export { resolveSource, resolveSources } from './resolve-source';
|
|
7
|
+
export { RecordingPresets, IOSOutputFormat, AudioQuality, } from './recording-presets';
|
|
8
|
+
export { PLAYBACK_STATUS_UPDATE, AUDIO_SAMPLE_UPDATE, RECORDING_STATUS_UPDATE, PLAYLIST_STATUS_UPDATE, TRACK_CHANGED, AUDIO_STREAM_BUFFER, AUDIO_STREAM_STATUS, } from './types';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACnC,4BAA4B,EAC5B,OAAO,EACP,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { SharedObject } from 'expo-modules-core';
|
|
2
|
+
import type { PermissionResponse } from 'expo-modules-core';
|
|
3
|
+
import type { IAudioMetadata, IAudioMode, IAudioPlaylistLoopMode, IAudioSample, IAudioSource, IAudioStatus, IAudioLockScreenOptions, IAudioPlaylistStatus, IPitchCorrectionQuality, IRecorderState, IRecordingInput, IRecordingOptions, IRecordingStartOptions, IRecordingStatus } from './types';
|
|
4
|
+
export type NativeAudioPlayerEvents = {
|
|
5
|
+
playbackStatusUpdate(status: IAudioStatus): void;
|
|
6
|
+
audioSampleUpdate(data: IAudioSample): void;
|
|
7
|
+
};
|
|
8
|
+
export declare class NativeAudioPlayer extends SharedObject<NativeAudioPlayerEvents> {
|
|
9
|
+
constructor(source: IAudioSource, updateInterval: number, keepAudioSessionActive: boolean, preferredForwardBufferDuration: number);
|
|
10
|
+
id: string;
|
|
11
|
+
playing: boolean;
|
|
12
|
+
muted: boolean;
|
|
13
|
+
loop: boolean;
|
|
14
|
+
paused: boolean;
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
isAudioSamplingSupported: boolean;
|
|
17
|
+
isBuffering: boolean;
|
|
18
|
+
currentTime: number;
|
|
19
|
+
duration: number;
|
|
20
|
+
volume: number;
|
|
21
|
+
playbackRate: number;
|
|
22
|
+
shouldCorrectPitch: boolean;
|
|
23
|
+
currentStatus: IAudioStatus;
|
|
24
|
+
play(): void;
|
|
25
|
+
pause(): void;
|
|
26
|
+
replace(source: IAudioSource): void;
|
|
27
|
+
seekTo(seconds: number, toleranceMillisBefore?: number, toleranceMillisAfter?: number): Promise<void>;
|
|
28
|
+
setPlaybackRate(rate: number, pitchCorrectionQuality?: IPitchCorrectionQuality): void;
|
|
29
|
+
setAudioSamplingEnabled(enabled: boolean): void;
|
|
30
|
+
setActiveForLockScreen(active: boolean, metadata?: IAudioMetadata, options?: IAudioLockScreenOptions): void;
|
|
31
|
+
updateLockScreenMetadata(metadata: IAudioMetadata): void;
|
|
32
|
+
clearLockScreenControls(): void;
|
|
33
|
+
remove(): void;
|
|
34
|
+
}
|
|
35
|
+
export type NativeAudioRecorderEvents = {
|
|
36
|
+
recordingStatusUpdate: (status: IRecordingStatus) => void;
|
|
37
|
+
};
|
|
38
|
+
export declare class NativeAudioRecorder extends SharedObject<NativeAudioRecorderEvents> {
|
|
39
|
+
constructor(options: Partial<IRecordingOptions>);
|
|
40
|
+
id: string;
|
|
41
|
+
currentTime: number;
|
|
42
|
+
isRecording: boolean;
|
|
43
|
+
uri: string | null;
|
|
44
|
+
record(options?: IRecordingStartOptions): void;
|
|
45
|
+
stop(): Promise<void>;
|
|
46
|
+
pause(): void;
|
|
47
|
+
getAvailableInputs(): IRecordingInput[];
|
|
48
|
+
getCurrentInput(): Promise<IRecordingInput>;
|
|
49
|
+
setInput(inputUid: string): void;
|
|
50
|
+
getStatus(): IRecorderState;
|
|
51
|
+
/** @deprecated Use `record({ atTime: seconds })` instead. */
|
|
52
|
+
startRecordingAtTime(seconds: number): void;
|
|
53
|
+
prepareToRecordAsync(options?: Partial<IRecordingOptions>): Promise<void>;
|
|
54
|
+
/** @deprecated Use `record({ forDuration: seconds })` instead. */
|
|
55
|
+
recordForDuration(seconds: number): void;
|
|
56
|
+
}
|
|
57
|
+
export type NativeAudioPlaylistEvents = {
|
|
58
|
+
playlistStatusUpdate(status: IAudioPlaylistStatus): void;
|
|
59
|
+
trackChanged(data: {
|
|
60
|
+
previousIndex: number;
|
|
61
|
+
currentIndex: number;
|
|
62
|
+
}): void;
|
|
63
|
+
};
|
|
64
|
+
export declare class NativeAudioPlaylist extends SharedObject<NativeAudioPlaylistEvents> {
|
|
65
|
+
constructor(sources: IAudioSource[], updateInterval: number, loop: IAudioPlaylistLoopMode);
|
|
66
|
+
id: string;
|
|
67
|
+
readonly currentIndex: number;
|
|
68
|
+
readonly trackCount: number;
|
|
69
|
+
readonly sources: {
|
|
70
|
+
uri?: string;
|
|
71
|
+
name?: string;
|
|
72
|
+
}[];
|
|
73
|
+
playing: boolean;
|
|
74
|
+
muted: boolean;
|
|
75
|
+
isLoaded: boolean;
|
|
76
|
+
isBuffering: boolean;
|
|
77
|
+
currentTime: number;
|
|
78
|
+
duration: number;
|
|
79
|
+
volume: number;
|
|
80
|
+
playbackRate: number;
|
|
81
|
+
loop: IAudioPlaylistLoopMode;
|
|
82
|
+
currentStatus: IAudioPlaylistStatus;
|
|
83
|
+
play(): void;
|
|
84
|
+
pause(): void;
|
|
85
|
+
next(): void;
|
|
86
|
+
previous(): void;
|
|
87
|
+
skipTo(index: number): void;
|
|
88
|
+
seekTo(seconds: number): Promise<void>;
|
|
89
|
+
add(source: IAudioSource): void;
|
|
90
|
+
insert(source: IAudioSource, index: number): void;
|
|
91
|
+
remove(index: number): void;
|
|
92
|
+
clear(): void;
|
|
93
|
+
destroy(): void;
|
|
94
|
+
}
|
|
95
|
+
export type NativeAudioStreamEvents = {
|
|
96
|
+
audioStreamBuffer(buffer: {
|
|
97
|
+
data: ArrayBuffer;
|
|
98
|
+
sampleRate: number;
|
|
99
|
+
channels: number;
|
|
100
|
+
timestamp: number;
|
|
101
|
+
}): void;
|
|
102
|
+
audioStreamStatus(status: {
|
|
103
|
+
isStreaming: boolean;
|
|
104
|
+
}): void;
|
|
105
|
+
};
|
|
106
|
+
export declare class NativeAudioStream extends SharedObject<NativeAudioStreamEvents> {
|
|
107
|
+
constructor(options: {
|
|
108
|
+
sampleRate: number;
|
|
109
|
+
channels: number;
|
|
110
|
+
encoding: string;
|
|
111
|
+
});
|
|
112
|
+
id: string;
|
|
113
|
+
readonly sampleRate: number;
|
|
114
|
+
readonly channels: number;
|
|
115
|
+
readonly isStreaming: boolean;
|
|
116
|
+
start(): Promise<void>;
|
|
117
|
+
stop(): void;
|
|
118
|
+
}
|
|
119
|
+
export type INativeAudioModule = {
|
|
120
|
+
readonly AudioPlayer: typeof NativeAudioPlayer;
|
|
121
|
+
readonly AudioRecorder: typeof NativeAudioRecorder;
|
|
122
|
+
readonly AudioPlaylist: typeof NativeAudioPlaylist;
|
|
123
|
+
readonly AudioStream: typeof NativeAudioStream;
|
|
124
|
+
setIsAudioActiveAsync(active: boolean): Promise<void>;
|
|
125
|
+
setAudioModeAsync(mode: Partial<IAudioMode>): Promise<void>;
|
|
126
|
+
requestRecordingPermissionsAsync(): Promise<PermissionResponse>;
|
|
127
|
+
requestNotificationPermissionsAsync(): Promise<PermissionResponse>;
|
|
128
|
+
getRecordingPermissionsAsync(): Promise<PermissionResponse>;
|
|
129
|
+
preload(source: IAudioSource, preferredForwardBufferDuration: number): Promise<void>;
|
|
130
|
+
clearPreloadedSource(source: IAudioSource): Promise<void>;
|
|
131
|
+
clearAllPreloadedSources(): Promise<void>;
|
|
132
|
+
getPreloadedSources(): Promise<string[]>;
|
|
133
|
+
};
|
|
134
|
+
export declare const expoAudio: INativeAudioModule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAoLtE,MAAM,CAAC,MAAM,SAAS,GAAG,mBAAmB,CAAqB,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IRecordingOptions } from './types';
|
|
2
|
+
/** @platform ios */
|
|
3
|
+
export declare enum IOSOutputFormat {
|
|
4
|
+
LINEARPCM = "lpcm",
|
|
5
|
+
AC3 = "ac-3",
|
|
6
|
+
'60958AC3' = "cac3",
|
|
7
|
+
APPLEIMA4 = "ima4",
|
|
8
|
+
MPEG4AAC = "aac ",
|
|
9
|
+
MPEG4CELP = "celp",
|
|
10
|
+
MPEG4HVXC = "hvxc",
|
|
11
|
+
MPEG4TWINVQ = "twvq",
|
|
12
|
+
MACE3 = "MAC3",
|
|
13
|
+
MACE6 = "MAC6",
|
|
14
|
+
ULAW = "ulaw",
|
|
15
|
+
ALAW = "alaw",
|
|
16
|
+
QDESIGN = "QDMC",
|
|
17
|
+
QDESIGN2 = "QDM2",
|
|
18
|
+
QUALCOMM = "Qclp",
|
|
19
|
+
MPEGLAYER1 = ".mp1",
|
|
20
|
+
MPEGLAYER2 = ".mp2",
|
|
21
|
+
MPEGLAYER3 = ".mp3",
|
|
22
|
+
APPLELOSSLESS = "alac",
|
|
23
|
+
MPEG4AAC_HE = "aach",
|
|
24
|
+
MPEG4AAC_LD = "aacl",
|
|
25
|
+
MPEG4AAC_ELD = "aace",
|
|
26
|
+
MPEG4AAC_ELD_SBR = "aacf",
|
|
27
|
+
MPEG4AAC_ELD_V2 = "aacg",
|
|
28
|
+
MPEG4AAC_HE_V2 = "aacp",
|
|
29
|
+
MPEG4AAC_SPATIAL = "aacs",
|
|
30
|
+
AMR = "samr",
|
|
31
|
+
AMR_WB = "sawb",
|
|
32
|
+
AUDIBLE = "AUDB",
|
|
33
|
+
ILBC = "ilbc",
|
|
34
|
+
DVIINTELIMA = 1836253201,
|
|
35
|
+
MICROSOFTGSM = 1836253233,
|
|
36
|
+
AES3 = "aes3",
|
|
37
|
+
ENHANCEDAC3 = "ec-3"
|
|
38
|
+
}
|
|
39
|
+
export declare enum AudioQuality {
|
|
40
|
+
MIN = 0,
|
|
41
|
+
LOW = 32,
|
|
42
|
+
MEDIUM = 64,
|
|
43
|
+
HIGH = 96,
|
|
44
|
+
MAX = 127
|
|
45
|
+
}
|
|
46
|
+
/** The two preset `IRecordingOptions` bundles expo-audio ships. */
|
|
47
|
+
export declare const RecordingPresets: {
|
|
48
|
+
readonly HIGH_QUALITY: IRecordingOptions;
|
|
49
|
+
readonly LOW_QUALITY: IRecordingOptions;
|
|
50
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** @platform ios */
|
|
2
|
+
export var IOSOutputFormat;
|
|
3
|
+
(function (IOSOutputFormat) {
|
|
4
|
+
IOSOutputFormat["LINEARPCM"] = "lpcm";
|
|
5
|
+
IOSOutputFormat["AC3"] = "ac-3";
|
|
6
|
+
IOSOutputFormat["60958AC3"] = "cac3";
|
|
7
|
+
IOSOutputFormat["APPLEIMA4"] = "ima4";
|
|
8
|
+
IOSOutputFormat["MPEG4AAC"] = "aac ";
|
|
9
|
+
IOSOutputFormat["MPEG4CELP"] = "celp";
|
|
10
|
+
IOSOutputFormat["MPEG4HVXC"] = "hvxc";
|
|
11
|
+
IOSOutputFormat["MPEG4TWINVQ"] = "twvq";
|
|
12
|
+
IOSOutputFormat["MACE3"] = "MAC3";
|
|
13
|
+
IOSOutputFormat["MACE6"] = "MAC6";
|
|
14
|
+
IOSOutputFormat["ULAW"] = "ulaw";
|
|
15
|
+
IOSOutputFormat["ALAW"] = "alaw";
|
|
16
|
+
IOSOutputFormat["QDESIGN"] = "QDMC";
|
|
17
|
+
IOSOutputFormat["QDESIGN2"] = "QDM2";
|
|
18
|
+
IOSOutputFormat["QUALCOMM"] = "Qclp";
|
|
19
|
+
IOSOutputFormat["MPEGLAYER1"] = ".mp1";
|
|
20
|
+
IOSOutputFormat["MPEGLAYER2"] = ".mp2";
|
|
21
|
+
IOSOutputFormat["MPEGLAYER3"] = ".mp3";
|
|
22
|
+
IOSOutputFormat["APPLELOSSLESS"] = "alac";
|
|
23
|
+
IOSOutputFormat["MPEG4AAC_HE"] = "aach";
|
|
24
|
+
IOSOutputFormat["MPEG4AAC_LD"] = "aacl";
|
|
25
|
+
IOSOutputFormat["MPEG4AAC_ELD"] = "aace";
|
|
26
|
+
IOSOutputFormat["MPEG4AAC_ELD_SBR"] = "aacf";
|
|
27
|
+
IOSOutputFormat["MPEG4AAC_ELD_V2"] = "aacg";
|
|
28
|
+
IOSOutputFormat["MPEG4AAC_HE_V2"] = "aacp";
|
|
29
|
+
IOSOutputFormat["MPEG4AAC_SPATIAL"] = "aacs";
|
|
30
|
+
IOSOutputFormat["AMR"] = "samr";
|
|
31
|
+
IOSOutputFormat["AMR_WB"] = "sawb";
|
|
32
|
+
IOSOutputFormat["AUDIBLE"] = "AUDB";
|
|
33
|
+
IOSOutputFormat["ILBC"] = "ilbc";
|
|
34
|
+
IOSOutputFormat[IOSOutputFormat["DVIINTELIMA"] = 1836253201] = "DVIINTELIMA";
|
|
35
|
+
IOSOutputFormat[IOSOutputFormat["MICROSOFTGSM"] = 1836253233] = "MICROSOFTGSM";
|
|
36
|
+
IOSOutputFormat["AES3"] = "aes3";
|
|
37
|
+
IOSOutputFormat["ENHANCEDAC3"] = "ec-3";
|
|
38
|
+
})(IOSOutputFormat || (IOSOutputFormat = {}));
|
|
39
|
+
export var AudioQuality;
|
|
40
|
+
(function (AudioQuality) {
|
|
41
|
+
AudioQuality[AudioQuality["MIN"] = 0] = "MIN";
|
|
42
|
+
AudioQuality[AudioQuality["LOW"] = 32] = "LOW";
|
|
43
|
+
AudioQuality[AudioQuality["MEDIUM"] = 64] = "MEDIUM";
|
|
44
|
+
AudioQuality[AudioQuality["HIGH"] = 96] = "HIGH";
|
|
45
|
+
AudioQuality[AudioQuality["MAX"] = 127] = "MAX";
|
|
46
|
+
})(AudioQuality || (AudioQuality = {}));
|
|
47
|
+
const HIGH_QUALITY = {
|
|
48
|
+
extension: '.m4a',
|
|
49
|
+
sampleRate: 44100,
|
|
50
|
+
numberOfChannels: 2,
|
|
51
|
+
bitRate: 128000,
|
|
52
|
+
android: {
|
|
53
|
+
outputFormat: 'mpeg4',
|
|
54
|
+
audioEncoder: 'aac',
|
|
55
|
+
},
|
|
56
|
+
ios: {
|
|
57
|
+
outputFormat: IOSOutputFormat.MPEG4AAC,
|
|
58
|
+
audioQuality: AudioQuality.MAX,
|
|
59
|
+
linearPCMBitDepth: 16,
|
|
60
|
+
linearPCMIsBigEndian: false,
|
|
61
|
+
linearPCMIsFloat: false,
|
|
62
|
+
},
|
|
63
|
+
web: {
|
|
64
|
+
mimeType: 'audio/webm',
|
|
65
|
+
bitsPerSecond: 128000,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const LOW_QUALITY = {
|
|
69
|
+
extension: '.m4a',
|
|
70
|
+
sampleRate: 44100,
|
|
71
|
+
numberOfChannels: 2,
|
|
72
|
+
bitRate: 64000,
|
|
73
|
+
android: {
|
|
74
|
+
extension: '.3gp',
|
|
75
|
+
outputFormat: '3gp',
|
|
76
|
+
audioEncoder: 'amr_nb',
|
|
77
|
+
},
|
|
78
|
+
ios: {
|
|
79
|
+
audioQuality: AudioQuality.MIN,
|
|
80
|
+
outputFormat: IOSOutputFormat.MPEG4AAC,
|
|
81
|
+
linearPCMBitDepth: 16,
|
|
82
|
+
linearPCMIsBigEndian: false,
|
|
83
|
+
linearPCMIsFloat: false,
|
|
84
|
+
},
|
|
85
|
+
web: {
|
|
86
|
+
mimeType: 'audio/webm',
|
|
87
|
+
bitsPerSecond: 128000,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
/** The two preset `IRecordingOptions` bundles expo-audio ships. */
|
|
91
|
+
export const RecordingPresets = {
|
|
92
|
+
HIGH_QUALITY,
|
|
93
|
+
LOW_QUALITY,
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=recording-presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recording-presets.js","sourceRoot":"","sources":["../../src/core/recording-presets.ts"],"names":[],"mappings":"AAGA,oBAAoB;AACpB,MAAM,CAAN,IAAY,eAmCX;AAnCD,WAAY,eAAe;IACzB,qCAAkB,CAAA;IAClB,+BAAY,CAAA;IACZ,oCAAmB,CAAA;IACnB,qCAAkB,CAAA;IAClB,oCAAiB,CAAA;IACjB,qCAAkB,CAAA;IAClB,qCAAkB,CAAA;IAClB,uCAAoB,CAAA;IACpB,iCAAc,CAAA;IACd,iCAAc,CAAA;IACd,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,mCAAgB,CAAA;IAChB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,yCAAsB,CAAA;IACtB,uCAAoB,CAAA;IACpB,uCAAoB,CAAA;IACpB,wCAAqB,CAAA;IACrB,4CAAyB,CAAA;IACzB,2CAAwB,CAAA;IACxB,0CAAuB,CAAA;IACvB,4CAAyB,CAAA;IACzB,+BAAY,CAAA;IACZ,kCAAe,CAAA;IACf,mCAAgB,CAAA;IAChB,gCAAa,CAAA;IACb,4EAAwB,CAAA;IACxB,8EAAyB,CAAA;IACzB,gCAAa,CAAA;IACb,uCAAoB,CAAA;AACtB,CAAC,EAnCW,eAAe,KAAf,eAAe,QAmC1B;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,6CAAO,CAAA;IACP,8CAAU,CAAA;IACV,oDAAa,CAAA;IACb,gDAAW,CAAA;IACX,+CAAU,CAAA;AACZ,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAED,MAAM,YAAY,GAAsB;IACtC,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM;IACf,OAAO,EAAE;QACP,YAAY,EAAE,OAAO;QACrB,YAAY,EAAE,KAAK;KACpB;IACD,GAAG,EAAE;QACH,YAAY,EAAE,eAAe,CAAC,QAAQ;QACtC,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,iBAAiB,EAAE,EAAE;QACrB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB,EAAE,KAAK;KACxB;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,YAAY;QACtB,aAAa,EAAE,MAAM;KACtB;CACF,CAAC;AAEF,MAAM,WAAW,GAAsB;IACrC,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,CAAC;IACnB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACP,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD,GAAG,EAAE;QACH,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,YAAY,EAAE,eAAe,CAAC,QAAQ;QACtC,iBAAiB,EAAE,EAAE;QACrB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB,EAAE,KAAK;KACxB;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,YAAY;QACtB,aAAa,EAAE,MAAM;KACtB;CACF,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY;IACZ,WAAW;CACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAudioSource } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a source into the shape the native player accepts. A `number` (a `require()`'d
|
|
4
|
+
* local asset) resolves via `@symbiote-native/engine`'s `resolveAssetSource` seam — RN's own
|
|
5
|
+
* generic asset-registry lookup, wired by `bootstrapHost`. An actual `expo-asset` `Asset`
|
|
6
|
+
* instance is still not ported, see `types.ts`'s header comment on `IAudioSource`. A plain
|
|
7
|
+
* string is treated as a URI, matching upstream.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveSource(source?: IAudioSource): IAudioSource | null;
|
|
10
|
+
export declare function resolveSources(sources: IAudioSource[]): NonNullable<IAudioSource>[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { resolveAssetSource } from '@symbiote-native/engine';
|
|
2
|
+
// resolveAssetSource returns `unknown` by design (the seam serves every require()'d-asset
|
|
3
|
+
// consumer, not just this package) — narrow it instead of casting.
|
|
4
|
+
function isAudioSourceObject(value) {
|
|
5
|
+
return typeof value === 'object' && value !== null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes a source into the shape the native player accepts. A `number` (a `require()`'d
|
|
9
|
+
* local asset) resolves via `@symbiote-native/engine`'s `resolveAssetSource` seam — RN's own
|
|
10
|
+
* generic asset-registry lookup, wired by `bootstrapHost`. An actual `expo-asset` `Asset`
|
|
11
|
+
* instance is still not ported, see `types.ts`'s header comment on `IAudioSource`. A plain
|
|
12
|
+
* string is treated as a URI, matching upstream.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveSource(source) {
|
|
15
|
+
if (source == null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (typeof source === 'number') {
|
|
19
|
+
const resolved = resolveAssetSource(source);
|
|
20
|
+
return isAudioSourceObject(resolved) ? resolved : null;
|
|
21
|
+
}
|
|
22
|
+
if (typeof source === 'string') {
|
|
23
|
+
return { uri: source };
|
|
24
|
+
}
|
|
25
|
+
return source;
|
|
26
|
+
}
|
|
27
|
+
export function resolveSources(sources) {
|
|
28
|
+
return sources
|
|
29
|
+
.map(source => resolveSource(source))
|
|
30
|
+
.filter((source) => source != null);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=resolve-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-source.js","sourceRoot":"","sources":["../../src/core/resolve-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,0FAA0F;AAC1F,mEAAmE;AACnE,SAAS,mBAAmB,CAC1B,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAAuB;IAEvB,OAAO,OAAO;SACX,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SACpC,MAAM,CAAC,CAAC,MAAM,EAAuC,EAAE,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;AAC7E,CAAC"}
|