---
title: Getting started
description: Install Frustbite and read your first audio file.
---

## Install Frustbite

```yaml title="pubspec.yaml"
dependencies:
  frustbite: ^0.0.2
```

```bash
dart pub get
```

The package bundles the prebuilt native binary for every platform, and its
build hook picks the one for the current target. The build is offline: nothing
is downloaded and no Rust toolchain is needed. The hook verifies each binary
against a SHA-256 hash that ships in the package. The package and the binary
must have the same ABI version, which the package checks at load time.

## Platform requirements

The prebuilt binaries target these minimum OS versions:

| Platform | Minimum |
| --- | --- |
| iOS | 16.0 |
| macOS | 13.0 |
| Android | API 30 (Android 11) |
| Linux | glibc-based distributions with glibc ≥ 2.17 (CentOS 7 and newer); musl distributions such as Alpine are not supported |

A Flutter app has to raise its own minimums to match:

- **iOS**: in `ios/Podfile` set `platform :ios, '16.0'`, and set the iOS
  Deployment Target of the Runner target to 16.0 in Xcode.
- **macOS**: in `macos/Podfile` set `platform :osx, '13.0'`, and set
  `MACOSX_DEPLOYMENT_TARGET = 13.0` (Xcode: macOS Deployment Target).
- **Android**: in `android/app/build.gradle(.kts)` set `minSdk = 30`
  (`minSdkVersion 30` in older Groovy files).

For other minimums, build from source (see
[Formats and build](/frustbite/formats-and-build)).

## iOS privacy manifest

Apple requires an app to declare the "required reason" APIs that it and its
libraries call. The iOS libraries import `stat` and `fstat` (the Rust standard
library uses them to open a file and read its size), which Apple lists under
the **file timestamp** category. Frustbite never reads or exposes a timestamp,
but Apple matches on the API. No other required-reason API is imported (not
`getattrlist`, `mach_absolute_time`, `statfs` or `statvfs`). A pure Dart
package cannot ship its own `PrivacyInfo.xcprivacy`, so declare the category in
your app's `ios/Runner/PrivacyInfo.xcprivacy`. Put this fragment inside the
top-level `<dict>` of that file:

```xml
<key>NSPrivacyAccessedAPITypes</key>
<array>
  <dict>
    <key>NSPrivacyAccessedAPIType</key>
    <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
    <key>NSPrivacyAccessedAPITypeReasons</key>
    <array>
      <!-- files inside the app container (bundled or downloaded assets) -->
      <string>C617.1</string>
      <!-- files the user picked, for example with a document picker -->
      <string>3B52.1</string>
    </array>
  </dict>
</array>
```

Keep only the reasons that match your app: `C617.1` if it opens audio in its
own container, `3B52.1` if it opens files the user granted access to. macOS
needs no manifest.

## Open a source

Open a path on native platforms:

```dart
final audio = Frustbite.fromFile('song.mp3');
```

Or open bytes on every platform, including the web:

```dart
final bytes = await File('song.mp3').readAsBytes();
final audio = Frustbite.fromMemory(bytes);
```

The container is detected from the content. The optional `format:` argument
(an `AudioContainer`) is only an advisory hint: content detection wins, and a
wrong hint is not an error.

Always release the native resources when you are done:

```dart
try {
  // use audio
} finally {
  audio.dispose();
}
```

Finalizers are only a safety net. Using a disposed instance throws
`StateError`.

## Read the stream info

```dart
final info = audio.info;
print(info.container); // AudioContainer.mp3
print(info.codec); // AudioCodec.mp3
print(info.sampleRate); // 44100
print(info.channels); // 2
print(info.duration); // 0:03:00.000000
```

`info`, `tags` and `cover` are cached after the first read.

## Handle errors

Every engine error is a `FrustbiteException`:

```dart
try {
  final audio = Frustbite.fromFile(path);
  // ...
} on UnsupportedFormatException {
  // not an audio file, or a format that is not supported
} on DecodingException {
  // empty or corrupt data
} on InvalidPathException {
  // empty or missing path
} on FrustbiteException catch (e) {
  print(e.code);
}
```

## Next steps

See [Reading audio](/frustbite/reading-audio) for tags, cover art, waveforms and
decoding, [WebAssembly](/frustbite/webassembly) for browser setup, and
[Formats and build](/frustbite/formats-and-build) for what is supported.
