Beispiel #1
0
        public async Task <PandoraResult> GetNowPlaying(bool lastFM)
        {
            ConnectIfNotConnected();

            var song   = GetCurrentSong();
            var status = GetStatus();

            var lastFMService = new LastFMService();

            var result = new PandoraResult
            {
                Album           = song.Album,
                AlbumUri        = null,
                Artist          = song.Artist,
                DurationSeconds = status.TimeTotal,
                Loved           = false,
                Song            = song.Title,
                Radio           = song.Genre
            };

            if (lastFM)
            {
                result.Loved    = (await lastFMService.GetSongInfo(result.Artist, result.Song))?.IsLoved ?? false;
                result.AlbumUri = (await lastFMService.GetAlbumInfo(result.Artist, result.Album))?.ImageUrl?.ToString();
            }

            return(result);
        }
Beispiel #2
0
        public void SongChange(PandoraResult pandoraResult)
        {
            using (var channel = _connection.CreateModel())
            {
                channel.ExchangeDeclare("song-change", "fanout");

                var message = JsonConvert.SerializeObject(pandoraResult);
                var body    = Encoding.UTF8.GetBytes(message);
                channel.BasicPublish(exchange: "song-change",
                                     routingKey: "",
                                     basicProperties: null,
                                     body: body);
            }
        }