コード例 #1
0
        public PlayerMedia(StatusResponse response, Uri endpoint)
        {
            if (response == null)
            {
                throw new ArgumentNullException(nameof(response));
            }

            ImageUri = response.Image != null?BluParser.ParseAbsoluteUri(response.Image, endpoint) : null;

            ServiceIconUri = response.ServiceIcon != null?BluParser.ParseAbsoluteUri(response.ServiceIcon, endpoint) : null;

            Titles = new[] { response.Title1, response.Title2, response.Title3 }.Where(element => element != null).ToArray();
        }
コード例 #2
0
ファイル: MusicContentEntry.cs プロジェクト: roblans/Blu4Net
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 public PlayerPreset(PresetsResponse.Preset response, Uri endpoint)
 {
     Number   = response.ID;
     Name     = response.Name;
     ImageUri = BluParser.ParseAbsoluteUri(response.Image, endpoint);
 }
コード例 #5
0
        public async Task <PlayerState> Stop()
        {
            var response = await _channel.Stop().ConfigureAwait(false);

            return(BluParser.ParseState(response.State));
        }
コード例 #6
0
        public async Task <PlayerState> Pause(bool toggle = false)
        {
            var response = await _channel.Pause(toggle? 1 : 0).ConfigureAwait(false);

            return(BluParser.ParseState(response.State));
        }
コード例 #7
0
        public async Task <PlayerState> Seek(TimeSpan offset)
        {
            var response = await _channel.Play((int)offset.TotalSeconds).ConfigureAwait(false);

            return(BluParser.ParseState(response.State));
        }