private async Task <AudioTrack> GetNextStation(string name) { try { DISettingsCache cache = Serialize.Open <DISettingsCache>("di.xml"); List <Station> stations = Serialize.Open <List <Station> >("stationcache.xml"); Station nextStation = StationNavigator.GetNextStation(name, stations); if (nextStation != null) { TrackListDownloader downloader = new TrackListDownloader(); List <Track> tracks = await downloader.GetTracksForStation(nextStation.JSONID); string trackName = string.Empty; if (tracks != null) { trackName = tracks[0].FullTrackName; } Uri location; if (cache != null && cache.IsPremiumEnabled) { location = new Uri(nextStation.PremiumLocation + "?" + cache.PremiumKey); } else { location = new Uri(nextStation.Location); } return(new AudioTrack(location, trackName, nextStation.Name, string.Empty, null)); } else { return(null); } } catch { return(null); } }
private void NavigateToNextStation() { try { Station station = StationNavigator.GetNextStation(CoreViewModel.Instance.CurrentStation.Name, MainPageViewModel.Instance.Stations.ToList()); if (station == null) { MessageBox.Show("There are no stations after this one, so we can't do the switch.", "Beem", MessageBoxButton.OK); } else { CoreViewModel.Instance.CurrentStation = station; imgFave.Source = Utility.FavoriteImageSetter.GetImage(CoreViewModel.Instance.CurrentStation); CheckCurrentPlayingState(); } } catch { MessageBox.Show("Can't navigate to that station. It looks like that station is missing. Make sure you are connected to a network and try again.", "Beem", MessageBoxButton.OK); } }