public static async Task Initialize(TestContext context) { var endpoint = await BluEnvironment.ResolveEndpoints().FirstAsync(); Player = await BluPlayer.Connect(endpoint); Player.Log = new DelegateTextWriter((message => context.WriteLine(message))); }
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(); } }
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { var endpoint = await BluEnvironment.ResolveEndpoints().FirstOrDefaultAsync(); if (endpoint != null) { Player = await BluPlayer.Connect(endpoint); PlayerName = Player.Name; PlayerState = await Player.GetState(); Player.StateChanges.ObserveOnDispatcher().Subscribe(value => PlayerState = value); Volume = await Player.GetVolume(); Player.VolumeChanges.ObserveOnDispatcher().Subscribe(value => Volume = value); UpdateMedia(await Player.GetMedia()); Player.MediaChanges.ObserveOnDispatcher().Subscribe(UpdateMedia); } }
static async Task Main(string[] args) { var endpoint = await BluEnvironment.ResolveEndpoints().FirstOrDefaultAsync(); if (endpoint != null) { Console.WriteLine($"Endpoint: {endpoint}"); var player = await BluPlayer.Connect(endpoint); //player.Log = Console.Out; Console.WriteLine($"Player: {player.Name}"); Console.WriteLine(new string('=', 80)); await DumpPlayer(player); while (true) { var key = Console.ReadKey(true); if (key.KeyChar == 'q') { break; } if (key.KeyChar == 'p') { await DumpQueuedSongs(player.PlayQueue); } if (key.KeyChar == 'l') { var entry = player.MusicBrowser.Entries.SingleOrDefault(element => element.Name == "Library"); var node = await entry.Resolve(); await DumpMusicContentNode(node, 3); } if (key.KeyChar == 's') { Console.Write("Enter search term: "); var term = Console.ReadLine(); var entry = player.MusicBrowser.Entries.SingleOrDefault(element => element.Name == "Library"); var node = await entry.Resolve(); var search = await node.Search(term); await DumpMusicContentNode(search, 3); } if (Char.IsDigit(key.KeyChar)) { var number = (int)Char.GetNumericValue(key.KeyChar); if (number != 0) { await player.PresetList.LoadPreset(number); } } WriteInstructions(); } } else { Console.WriteLine("No player found!"); Console.WriteLine("Press 'q' to quit"); while (Console.ReadKey().KeyChar != 'q') { } } }