tauri-plugin-audioplayer 0.1.2

Tauri Audioplayer Plugin
docs.rs failed to build tauri-plugin-audioplayer-0.1.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: tauri-plugin-audioplayer-0.1.0

Tauri Plugin Audioplayer

tauri-plugin-audioplayer is a Tauri v2 desktop plugin for building native audio playback experiences. It exposes typed JavaScript bindings for discovering audio devices, selecting the input and output devices your application will use, loading a remote audio file, and controlling its playback from the frontend.

Audio is downloaded and decoded once into an in-memory interleaved f32 buffer. The plugin then renders that buffer through the selected CPAL output device, so play, pause, stop, progress reporting, and seeking work without downloading the track again. Symphonia provides broad container and codec support, with symphonia-adapter-libopus included for Opus files.

The current implementation manages one loaded track at a time. Audio stays internally as interleaved f32; playback prefers the decoded track's native sample rate and falls back to 48 kHz with high-quality offline resampling when necessary.

Installation

Install the rust part of the plugin

```bash
cargo add tauri-plugin-audioplayer
```

Install the js bindings

Use your preferred javascript package manager to add @audioland/tauri-plugin-audioplayer

```bash
pnpm add @audioland/tauri-plugin-audioplayer

npm add @audioland/tauri-plugin-audioplayer
```

Examples

Requirements

  • Git must be available in PATH. The Opus adapter is pinned to a Git revision, so Cargo uses Git during a clean dependency install.
  • Rust 1.90 or newer, including cargo, rustc, and the host target. The crate uses Rust edition 2024.
  • The platform prerequisites required by Tauri v2. On Windows this means the MSVC C++ build tools and Windows SDK; they are also required to build the bundled libopus adapter.
  • Node.js 20.19+ or 22.12+ and pnpm for the JavaScript bindings and the Svelte demo.
  • Internet access for the first cargo and pnpm install. Later builds can use the local dependency caches.
  • A working input and/or output device is required only to exercise device selection and playback; compilation and the automated tests do not open audio hardware.

Dependencies

The plugin uses CPAL for native audio I/O. Its selected backend depends on the target platform:

Platform Default backend Build dependencies
Linux PipeWire when available; ALSA fallback PipeWire development libraries and Clang (see below)
macOS CoreAudio Xcode command-line tools
Windows WASAPI MSVC C++ build tools and Windows SDK

On Linux, CPAL is compiled with its pipewire feature. When a PipeWire socket is available, cpal::default_host() uses PipeWire and enumerates its sinks; otherwise it falls back to ALSA. This avoids exposing ALSA's internal PCM plugins as selectable outputs on PipeWire-based desktop systems.

On Debian and Ubuntu, install the required build packages before compiling:

sudo apt install libpipewire-0.3-dev libspa-0.2-dev pkg-config clang libclang-dev

Feature Support

Feature Status Description
Desktop platforms 🟢 Windows, Linux, and macOS are declared as fully supported desktop targets.
Device discovery 🟢 Lists input and output devices with stable device IDs, a selected CPAL stream configuration, and every reported supported format, sample-rate range, channel count, and buffer range.
Device selection 🟢 Selects one input device and one output device by ID. Input capture is not implemented yet.
Audio formats 🟢 Support for AIFF, CAF, MP4/M4A, MKV/WebM, OGG, WAV, AAC, ALAC, FLAC, MP1/MP2/MP3, PCM, Vorbis and Opus audio codecs using Symphonia
Load into memory 🟢 Downloads and fully decodes a single audio track into an in-memory f32 interleaved buffer before playback.
Authenticated requests 🟢 Load into memory audio from authenticated sources
Playback controls 🟢 Play, pause, stop, playback progress, and seek commands operate on the loaded buffer. Seeking while playing continues from the selected position.
Adaptive output configuration 🟢 Prefers the decoded track's native sample rate and selects the best supported device format in this order: F32, I32, I16, then U16.
Sample-rate conversion 🟢 When the native source rate is unsupported, resamples the in-memory track to 48 kHz with Rubato's FFT resampler.
Output sample conversion 🟢 Keeps the playback pipeline in f32, converts only at the device callback, and applies TPDF dither for I16 and U16 output.

🟢 Supported    🟡 In Development    🔴 Planned

Contributing

We welcome contributions! Please see our Contributing Guidelines and Code of Conduct for details on how to get started.

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.