To use this plugin on the web platform, add the following scripts to your web/index.html:
<script src="assets/packages/flutter_soloud/web/libflutter_soloud_plugin.js" defer></script>
<script src="assets/packages/flutter_soloud/web/init_module.dart.js" defer></script>The web build uses a WebAssembly module that requires SharedArrayBuffer, which means it must be run with --wasm or served with cross-origin isolation headers. See the Web Platform Guide for details.
Linux distributions require the ALSA library for audio support. If missing, install it using your package manager:
# Debian/Ubuntu
sudo apt-get install libasound2-dev
# Arch Linux
sudo pacman -S alsa-lib
# OpenSUSE
sudo zypper install alsa-develIf you are linking the Xiph libraries (the default), you can also choose to use the TRY_SYSTEM_LIBS_FIRST=1 environment variable to link the ones available in the system:
# Default - use bundled libraries
flutter run
# Prefer system libraries, fallback to bundled
TRY_SYSTEM_LIBS_FIRST=1 flutter runSince the precompiled Xiph libraries are provided only for x86_64, you need to install them manually on the system:
sudo apt install libflac-dev libogg-dev libopus-dev libvorbis-devand then set the TRY_SYSTEM_LIBS_FIRST=1 environment variable to link them instead of the bundled ones:
TRY_SYSTEM_LIBS_FIRST=1 flutter runIf the Xiph libraries are not needed (for streaming purposes), you can also look here: Without Xiph libs
โ ๏ธ Using Swift Package Manager (SPM), packages cannot set Xcode build settings on the consuming app target. So when creating a release archive (IPA), you may need to modify symbol stripping to prevent errors:
- Open your project in Xcode
- Navigate to Target Runner > Build Settings > Strip Style
- Change from "All Symbols" to "Non-Global Symbols"
On macOS and iOS, the Swift Package Manager (SPM) can be used to build the plugin module. If SPM is not enabled, the build will be done using CocoaPods (using cmake). If the latter is used, please be sure you have cmake installed: brew install cmake.
Initialize SoLoud in your app:
void main() async {
await SoLoud.instance.init(
sampleRate: 44100, // Audio quality
bufferSize: 2048, // Buffer size affects latency
channels: Channels.stereo,
);
runApp(const MyApp());
}The bufferSize parameter affects audio latency, which generally means the time it takes from triggering a sound to the sound actually coming out of the speakers. The smaller the latency, the better, but could lead to choppy audio depending on the complexity of the audio processing. The default is 2048, but it can be adjusted to 1024 or 512.
- Initialize SoLoud early in your app lifecycle
- Handle initialization errors appropriately
- Configure buffer size based on your latency and app needs
- Clean up resources when your app closes