BluMiniPlayer sample app
Blu4Net is a .NET library that interfaces with BluOS players (Bluesound, NAD). It uses an event-driven (RX), non-blocking (async/await) model that makes it lightweight and efficient.
Supported Targets:
- .NET Standard: 2.0
- .NET Standard: 2.1
Requires C# 8.0 (due to the use of IAsyncEnumerable<T>)
Player endpoint discovery (mDNS)
- Play
- Seek (offset)
- Pause
- Stop
- Skip
- Back
- Shuffle (on | off)
- Repeat (off | one | all)
- Volume (percentage)
- Position (elapsed time + length of current track)
- Titles
- Image (artwork)
- Service icon
- Fetch presets
- Load preset (by number)
- Info (name + length)
- Fetch songs (paged)
- Clear
- Remove (song)
- Save (name)
- Browse hierarchy (note: partially implemented)
- Search (full-text)
- State changes (playing, paused, streaming, ...)
- Mode changes (shuffle, repeat)
- Volume changes
- Position changes (note: not realtime)
- Media changes
- Preset changes
- Queue changes
Install the NuGet package.
Install-Package Blu4Net
using Blu4Net;
using System;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
namespace GettingStarted
{
class Program
{
static async Task Main(string[] args)
{
// find endpoint of player (first one)
var endpoint = await BluEnvironment.ResolveEndpoints().FirstOrDefaultAsync();
Console.WriteLine($"Endpoint: {endpoint}");
// success?
if (endpoint != null)
{
// yes, so create and connect the player
var player = await BluPlayer.Connect(endpoint);
Console.WriteLine($"Player: {player}");
// get the state
var state = await player.GetState();
Console.WriteLine($"State: {state}");
// get the volume
var volume = await player.GetVolume();
Console.WriteLine($"Volume: {volume}");
// get the current playing media
var media = await player.GetMedia();
Console.WriteLine($"Media: {media.Titles.FirstOrDefault()}");
// subscribe to volume changes
using (player.VolumeChanges.Subscribe(volume => Console.WriteLine($"Volume: {volume}")))
{
Console.WriteLine();
Console.WriteLine($"Waiting for volume changes...");
Console.ReadLine();
}
}
else
{
Console.WriteLine("No endpoint found!");
Console.ReadLine();
}
}
}
}
See the BluDumper sample app for a complete example