Skip to main content
Version: Next

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 option.

Library setDefaultOptionWhat it adds
FFmpeg (libavcodec, libavformat, libavutil, libswresample)offenableFFmpegRemote URL streaming (HTTP byte ranges), HLS (.m3u8), remote URL metadata — see Runtime flags.
Static libs (libopus, libopusfile, libogg, libvorbis, libvorbisenc, libvorbisfile)ondisableStaticExternalLibsDecoding ogg, opus, oga files

The options are independent and can be combined.

Reducing app size

Leaving FFmpeg off (the default) and setting disableStaticExternalLibs can shave several MB off the final app size across all ABIs / device slices. Pick the set of formats you actually need and turn the rest off.

FFmpeg is opt-in

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.

Setting the options​

Every build (CocoaPods, Swift Package Manager and Gradle) reads the options from a react-native-audio-api section of the app's package.json. In an Expo app, pass them as Expo plugin options instead and expo prebuild writes that section for you.

app.json / app.config.js:

"plugins": [
[
"react-native-audio-api",
{
"enableFFmpeg": true,
"disableStaticExternalLibs": false
}
]
]

After changing them:

Run npx expo prebuild. It updates the package.json section from the plugin options and then runs pod install.

Enabling FFmpeg​

app.json / app.config.js:

"plugins": [
[
"react-native-audio-api",
{
"enableFFmpeg": true
}
]
]

With FFmpeg enabled, the FFmpeg binaries are downloaded during pod install / Swift package resolution / 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​

app.json / app.config.js:

"plugins": [
[
"react-native-audio-api",
{
"disableStaticExternalLibs": true
}
]
]

This removes the bundled Opus / Ogg / Vorbis static libraries. With this option 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.