Code Monkey home page Code Monkey logo

blu4net's Introduction

BluMiniPlayer sample app

Blu4Net

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>)

Features

Discovery

Player endpoint discovery (mDNS)

Basic operations

  • Play
  • Seek (offset)
  • Pause
  • Stop
  • Skip
  • Back
  • Shuffle (on | off)
  • Repeat (off | one | all)
  • Volume (percentage)
  • Position (elapsed time + length of current track)

Media information

  • Titles
  • Image (artwork)
  • Service icon

Presets

  • Fetch presets
  • Load preset (by number)

Queue

  • Info (name + length)
  • Fetch songs (paged)
  • Clear
  • Remove (song)
  • Save (name)

Music sources (Library, TuneIn, ...)

  • Browse hierarchy (note: partially implemented)
  • Search (full-text)

Notifications (Observable - ReactiveX)

  • State changes (playing, paused, streaming, ...)
  • Mode changes (shuffle, repeat)
  • Volume changes
  • Position changes (note: not realtime)
  • Media changes
  • Preset changes
  • Queue changes

Installation

Install the NuGet package.

Install-Package Blu4Net

Getting started

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

blu4net's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

blu4net's Issues

Nuget package with Xamarin VolumeResponse issue

When I use the nuget package in my xamarin (.android) project, the following piece of code gives a serialization problem:

#if NETSTANDARD2_0
        // workaround for: XmlSerializer works inconsistently with XmlTextAttribute on derived classes
        // https://github.com/dotnet/runtime/issues/22656
        [XmlText()]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public string VolumeInternal;
        public int Volume => int.Parse(VolumeInternal);
#else
        [XmlText()]
        public int Volume;
#endif

It seems that somehow the 2.1 lib ends up in the build, although the target framework is .Net standard 2.0. When I reference the project via a project reference (source code) everything is fine. Do you have a clue why this is?

Status response

Hi Rob,
I've noticed the PlayerMedia class does not capture all of the response attributes from the Status request. Is there a reason for that or did you only capture the ones that seemed important at the time?

Also, I may be missing something but can't seem to find a way to call GetStatus() from the the BluPlayer object to get the entire status response. Is this by design or am I using the wrong object? The only way I can do this is by creating another BluChannel and calling GetStatus() and then getting values of the fields from the Result, but is this the right way to accomplish this?

Thanks,
Scott.

C# - Recursively browse the BlueSound Menu System with DataGridView

Hi Rob,

I wanted to thank you for developing the Blu4Net library. It's been really useful for me and I appreciate your expertise in C#.

I've been trying to create an application that can browse the BlueSound Node menu system, starting at the top of the menu and navigating down to playing a radio station (similar to BlueSound's iOS application). I've been using the BluDumper example as a guide, but I'm having trouble implementing this in a Winform application using a DataGridView control. Do you have any suggestions for how I might be able to accomplish this?

Thanks,
Bill Hunter

long polling - how it works?

Hello Rob
i would like to control my bluesound device via javascript. Can you explain to me how to implement "long polling"?
Thank You

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.