SimpleAudioPlayer 2.3.2
dotnet add package SimpleAudioPlayer --version 2.3.2
NuGet\Install-Package SimpleAudioPlayer -Version 2.3.2
<PackageReference Include="SimpleAudioPlayer" Version="2.3.2" />
<PackageVersion Include="SimpleAudioPlayer" Version="2.3.2" />
<PackageReference Include="SimpleAudioPlayer" />
paket add SimpleAudioPlayer --version 2.3.2
#r "nuget: SimpleAudioPlayer, 2.3.2"
#:package SimpleAudioPlayer@2.3.2
#addin nuget:?package=SimpleAudioPlayer&version=2.3.2
#tool nuget:?package=SimpleAudioPlayer&version=2.3.2
SimpleAudioPlayer
A simple cross-platform audio playback library with SimpleAudioPlayer.Native (LGPL-2.1+) backend, supporting multiple audio formats and streaming protocols.
Features
- 🎵 Common audio formats support (via FFmpeg decoding)
- 📁 Multi-protocol handling: local files, HTTP streams, custom streams
- ⏯️ Basic playback controls: Play/Stop/Pause/Seek
- ⏲️ Track duration and progress monitoring
- 🔧 Extensible stream handling system (custom data sources)
What's New in 2.3.2
- Added sliding in-memory read cache (
MemoryReadCacheWindow) toDiskCachedStreamHandleandProgressiveHttpStreamHandleto reduce high-frequency disk I/O and eliminate audio stuttering during high disk load.
What's New in 2.3.1
- Native dependency updated to SimpleAudioPlayer.Native 2.3.1.
- Restored ARM/ARM64 NEON assembly on Linux and Android (via
-Bsymbolic).
What's New in 2.3.0
- Native dependency updated to SimpleAudioPlayer.Native 2.3.0.
- FFmpeg assembly optimizations enabled (x86_64 SSE/AVX via nasm on macOS/Windows).
- Fixed tail-of-file residual data being reported as a decode error instead of natural EOF.
What's New in 2.2.0
- Added
AudioPlayerOptionsfor output usage, content type, latency preference, sharing mode, and buffer tuning. - Defaults now use the device-native sample rate and a stable Media/Music playback configuration.
- Native dependency updated to SimpleAudioPlayer.Native 2.2.0.
- Playback failures now surface through
PlaybackFailedandPlaybackState.Error. - HTTP stream handlers report I/O failures instead of silently treating broken streams as EOF.
ProgressiveHttpStreamHandlesupports play-while-downloading to a final local file.DiskCachedStreamHandlecaches streamed data on disk to avoid holding large files in memory.
Installation Via NuGet:
Install-Package SimpleAudioPlayer -Version 2.3.2
Quick Start
// Create player instance
var player = new AudioPlayer();
// Use file stream (local path)
player.Load(new FileStreamHandler("song.mp3"));
// Get total duration in seconds
var duration = player.GetDuration();
// Playback controls
player.Play();
player.Stop();
player.Pause();
// Progress operations
var currentTime = player.GetTime();
player.Seek(30);
Output Device Configuration
The defaults target stable music playback with the device's native sample rate, media usage, music content, and shared output. Real-time workloads can opt into low latency:
var player = new AudioPlayer(new AudioPlayerOptions
{
LatencyMode = AudioLatencyMode.LowLatency,
Usage = AudioPlaybackUsage.Game,
ContentType = AudioContentType.Sonification,
SampleRate = 0, // Use the device's native sample rate.
ShareMode = AudioShareMode.Shared
});
Usage and ContentType map to backend settings where supported and safely retain platform defaults elsewhere. PeriodSizeInMilliseconds and Periods are available for advanced buffer tuning; leave them at 0 to use backend defaults.
Error Handling
player.PlaybackStateChanged = state =>
{
Console.WriteLine($"Playback state: {state}");
};
player.PlaybackFailed = args =>
{
Console.WriteLine($"Playback failed: {args.Result}");
Console.WriteLine(args.Exception);
};
Progressive HTTP Download
var handle = await ProgressiveHttpStreamHandle.CreateAsync(
"https://example.com/song.mp3",
"song.mp3",
overwrite: true);
handle.ProgressChanged += (downloaded, total) =>
{
Console.WriteLine($"{downloaded}/{total}");
};
handle.DownloadStateChanged += (_, args) =>
{
Console.WriteLine($"Download state: {args.State}");
};
player.Load(handle);
player.Play();
ProgressiveHttpStreamHandle keeps incomplete data in song.mp3.part and writes a compact binary song.mp3.part.idx index. By default resume: true reuses valid cached ranges, including ranges downloaded after seeking. If the URL identity or remote validators do not match, the partial cache is discarded and rebuilt.
Progressive Stream Cache
using var input = await httpClient.GetStreamAsync("https://example.com/song.mp3");
using var handle = new DiskCachedStreamHandle(input);
player.Load(handle);
player.Play();
DiskCachedStreamHandle is the stream-based play-while-downloading path. When no cache path is provided, it writes to a temporary .part file and deletes it on dispose. It advertises seek support when the source stream itself is seekable. For non-seekable streams, pass enableSeek: true only when cache-backed seeking after data has arrived is required.
To keep a completed stream as a cache file, pass a final cache path and enable commit-on-complete:
using var handle = new DiskCachedStreamHandle(
input,
totalSize: contentLength,
cacheFilePath: "song.mp3",
commitCacheOnComplete: true);
This writes to song.mp3.part while reading. Only a complete stream is moved to song.mp3; failed or incomplete streams delete the temporary .part file.
Stream Handlers
| Handler Type | Description |
|---|---|
FileStreamHandler |
Local file stream |
HttpStreamHandle |
HTTP network stream |
StreamHandle |
Generic stream (requires Stream object) |
CustomHandle |
Fully customizable implementation |
CachedStreamHandle |
Caching support for network streams |
DiskCachedStreamHandle |
Disk-backed cache for large streams |
ProgressiveHttpStreamHandle |
HTTP play-while-downloading with a final local file |
Dependencies
- Audio playback via miniaudio
- Audio decoding via FFmpeg
- Native component: SimpleAudioPlayer.Native 2.3.1 (LGPL-2.1+)
License - Main project: MIT License
- Native component: LGPL-2.1+
Important Compliance Notice:
When distributing software using this library, you MUST:
- Provide access to LGPL-licensed component's source code
- Allow end-users to replace the LGPL component
- Include full license texts
Contributing We welcome issues and pull requests! Please include:
- Steps to reproduce issues
- Relevant logs/error messages
- Environment details (OS/.NET version etc.)
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- SimpleAudioPlayer.Native (>= 2.3.1)
-
net8.0
- SimpleAudioPlayer.Native (>= 2.3.1)
-
net9.0
- SimpleAudioPlayer.Native (>= 2.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.2 | 106 | 8/17/2026 |
| 2.3.1 | 113 | 7/26/2026 |
| 2.3.0 | 85 | 7/25/2026 |
| 2.2.0 | 115 | 7/22/2026 |
| 2.1.1 | 98 | 6/24/2026 |
| 2.0.0 | 91 | 6/11/2026 |
| 1.8.4 | 140 | 5/25/2026 |
| 1.8.3 | 104 | 4/27/2026 |
| 1.8.2 | 291 | 7/27/2025 |
| 1.8.1 | 543 | 7/24/2025 |
| 1.8.0 | 316 | 4/16/2025 |
| 1.7.0 | 251 | 4/15/2025 |
| 1.5.2 | 211 | 3/28/2025 |
| 1.5.1 | 191 | 3/27/2025 |
| 1.5.0 | 198 | 3/27/2025 |
| 1.4.0 | 230 | 3/17/2025 |
| 1.3.0 | 219 | 3/13/2025 |
| 1.2.0 | 222 | 3/12/2025 |
| 1.1.0 | 225 | 3/10/2025 |
| 1.0.0 | 635 | 3/10/2025 |