public static async Task Initialize(TestContext context) { var enpoint = await BluEnvironment.ResolveEndpoints().FirstAsync(); Channel = new BluChannel(enpoint); Channel.Log = new DelegateTextWriter((message => context.WriteLine(message))); }
public PlayerPresetList(BluChannel channel, StatusResponse status) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); Changes = _channel.StatusChanges .SkipWhile(response => response.PresetsID == status.PresetsID) .DistinctUntilChanged(response => response.PresetsID) .SelectAsync(async _ => await GetPresets().ConfigureAwait(false)); }
public MusicContentNode(BluChannel channel, MusicContentNode parent, BrowseContentResponse response) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); Parent = parent; if (response == null) { throw new ArgumentNullException(nameof(response)); } _searchKey = response.SearchKey; ServiceName = response.ServiceName; Entries = response.Items != null?response.Items.Select(element => new MusicContentEntry(channel, this, element)).ToArray() : new MusicContentEntry[0]; }
public MusicContentEntry(BluChannel channel, MusicContentNode node, BrowseContentResponse.Item item) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); Node = node ?? throw new ArgumentNullException(nameof(node)); if (item == null) { throw new ArgumentNullException(nameof(item)); } _key = item.BrowseKey; Name = item.Text; Type = !string.IsNullOrEmpty(item.Type) ? item.Type.First().ToString().ToUpper() + item.Type.Substring(1) : null; ImageUri = BluParser.ParseAbsoluteUri(item.Image, channel.Endpoint); }
public static async Task <BluPlayer> Connect(Uri endpoint) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } var channel = new BluChannel(endpoint); var syncStatus = await channel.GetSyncStatus().ConfigureAwait(false); var status = await channel.GetStatus().ConfigureAwait(false); var content = await channel.BrowseContent().ConfigureAwait(false); return(new BluPlayer(channel, syncStatus, status, content)); }
private BluPlayer(BluChannel channel, SyncStatusResponse synStatus, StatusResponse status, BrowseContentResponse content) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); Endpoint = _channel.Endpoint; Name = synStatus.Name; Brand = synStatus.Brand; PresetList = new PlayerPresetList(_channel, status); PlayQueue = new PlayQueue(_channel, status); MusicBrowser = new MusicBrowser(_channel, content); VolumeChanges = _channel.VolumeChanges .SkipWhile(response => response.Decibel == status.Decibel) .DistinctUntilChanged(response => response.Decibel) .Select(response => response.Volume); StateChanges = _channel.StatusChanges .SkipWhile(response => response.State == status.State) .DistinctUntilChanged(response => response.State) .Select(response => BluParser.ParseState(response.State)); ShuffleModeChanges = _channel.StatusChanges .SkipWhile(response => response.Shuffle == status.Shuffle) .DistinctUntilChanged(response => response.Shuffle) .Select(response => (ShuffleMode)response.Shuffle); RepeatModeChanges = _channel.StatusChanges .SkipWhile(response => response.Repeat == status.Repeat) .DistinctUntilChanged(response => response.Repeat) .Select(response => (RepeatMode)response.Repeat); MediaChanges = _channel.StatusChanges .SkipWhile(response => response.Title1 == status.Title1 && response.Title2 == status.Title2 && response.Title3 == status.Title3) .DistinctUntilChanged(response => $"{response.Title1}{response.Title2}{response.Title3}") .Select(response => new PlayerMedia(response, Endpoint)); PositionChanges = _channel.StatusChanges .SkipWhile(response => response.Seconds == status.Seconds && response.TotalLength == status.TotalLength) .DistinctUntilChanged(response => $"{response.Seconds}{response.TotalLength}") .Select(response => new PlayPosition(response)); }
public MusicBrowser(BluChannel channel, BrowseContentResponse response) : base(channel, null, response) { }