public async Task <string> UpdateNowPlaying() { var pandoraInfo = _playerService.GetCurrentSongInfo(); var song = new SongDetails() { Album = pandoraInfo.Album, Artist = pandoraInfo.Artist, Song = pandoraInfo.Song }; return(await _lastFmService.UpdateNowPlaying(song)); }
public async Task SongChange(DeezerState deezerState) { if (File.Exists("deezer.json")) { var lastSong = _playerFactoryService.GetCurrentSongInfo(); if ((DateTime.UtcNow - lastSong.LastModifed) > TimeSpan.FromMinutes(1)) { await _lastFMService.StartScrobble(new SongDetails { Album = lastSong.Album, Song = lastSong.Song, Artist = lastSong.Artist }); } } var context = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <ServerHub>(); if (context == null) { return; } var pandoraInfo = new PandoraResult { Album = deezerState.AlbumName, AlbumUri = deezerState.AlbumUri, Artist = deezerState.ArtistName, IsPlaying = deezerState.IsPlaying, LastModifed = deezerState.UpdatedUtc, Loved = false, Radio = deezerState.StreamName, Song = deezerState.SongName }; RabbitMqService.SongChange(pandoraInfo); context.Clients.All.pandoraRefresh(pandoraInfo); var song = new SongDetails() { Album = pandoraInfo.Album, Artist = pandoraInfo.Artist, Song = pandoraInfo.Song }; await _lastFMService.UpdateNowPlaying(song); var json = JsonConvert.SerializeObject(deezerState); File.WriteAllText("deezer.json", json, Encoding.UTF8); }