Without Opus/Ogg

Configure builds without Opus and Ogg libraries to reduce binary size

Overview

The Opus and Ogg libraries are embedded by default in flutter_soloud. However, if you don't need streaming capabilities, you can exclude these libraries to reduce your app's binary size by 600~1500 KB (depending on platform).

Configuration Methods

Linux, Windows, Android

VS Code Configuration

Add to .vscode/launch.json:

{
  "name": "Flutter debug", // and/or other build configurations
  "type": "dart",
  "request": "launch",
  "program": "lib/main.dart",
  "env": {
    "NO_OPUS_OGG_LIBS": "1"
  }
}

Android Studio Setup

Add under Run/Debug Configurations:

Environment Variables: NO_OPUS_OGG_LIBS="1"

Screenshot

AS setup1
AS setup2

Command Line Build

# Build without Opus/Ogg
flutter clean
flutter pub get
NO_OPUS_OGG_LIBS="1" flutter run

# Reset to default (with Opus/Ogg)
flutter clean
flutter pub get
NO_OPUS_OGG_LIBS= flutter run  # Unsets the environment variable

iOS/MacOS Setup

Add to ios/Podfile or macos/Podfile:

ENV['NO_OPUS_OGG_LIBS'] = '1'
IDE environment variables are ignored for iOS and MacOS builds.

Web Platform

  1. Edit web/compile_wasm.sh
  2. Change NO_OPUS_OGG_LIBS="0" to NO_OPUS_OGG_LIBS="1"
  3. Rebuild WASM files (ie run web/compile_wasm.sh)

Requirements:

  • Emscripten installed
  • Linux or MacOS for compilation
  • Windows users need WSL
IDE environment variables are ignored for web builds.

Impact on Functionality

When built without Opus/Ogg:

  • setBufferStream() with Opus format will throw exceptions
  • Other audio formats remain fully functional
  • Binary size reduces by 600~1500 KB
  • All other features work normally