Prebuilt libraries support
react-native-audio-api can link a number of prebuilt third-party libraries that are downloaded at build time. They enable additional decoding and streaming features, but also add several megabytes to the resulting application binary, so each one can be toggled with a build flag.
| Library set | Default | Flag | What it adds |
|---|---|---|---|
FFmpeg (libavcodec, libavformat, libavutil, libswresample) | off | enableFFmpeg | Remote URL streaming (HTTP byte ranges), HLS (.m3u8), remote URL metadata — see Runtime flags. |
Static libs (libopus, libopusfile, libogg, libvorbis, libvorbisenc, libvorbisfile) | on | disableStaticExternalLibs | Decoding ogg, opus, oga files |
The flags are independent and can be combined.
Apps that would like to decode HLS or make use of URL streaming have to enable it explicitly (see below). Use isFfmpegEnabled to branch at runtime.
Enabling FFmpeg
- Expo
- iOS
- Android
Add an entry in the Audio API Expo plugin configuration:
"enableFFmpeg": true
Add an entry to the Podfile (before the targets), then run pod install:
ENV['ENABLE_AUDIOAPI_FFMPEG'] = '1'
In gradle.properties:
enableAudioapiFFmpeg=true
With FFmpeg enabled, the FFmpeg binaries are downloaded during pod install / the first Gradle build and linked into the app. FFmpeg is distributed under the LGPL — see THIRD_PARTY.md in the repository for the notice that applies to FFmpeg-enabled builds.
Disabling other external libraries
This removes the bundled Opus / Ogg / Vorbis static libraries. With this flag enabled, attempts to decode .ogg, .opus, or .oga files through AudioContext.decodeAudioData (or any other decoding path) will return an error — those formats are handled inside miniaudio via the now-disabled custom backends.
- Expo
- iOS
- Android
Add an entry in the Audio API Expo plugin configuration:
"disableStaticExternalLibs": true
Add an entry to the Podfile:
ENV['DISABLE_AUDIOAPI_STATIC_EXTERNAL_LIBS'] = '1'
In gradle.properties:
disableAudioapiStaticExternalLibs=true