Beispiel #1
0
        private async Task <AudioTrack> GetPreviousStation(string name)
        {
            try
            {
                DISettingsCache cache = Serialize.Open <DISettingsCache>("di.xml");

                List <Station> stations    = Serialize.Open <List <Station> >("stationcache.xml");
                Station        nextStation = StationNavigator.GetPreviousStation(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);
            }
        }
Beispiel #2
0
        private void NavigateToPreviousStation()
        {
            try
            {
                Station station = StationNavigator.GetPreviousStation(CoreViewModel.Instance.CurrentStation.Name,
                                                                      MainPageViewModel.Instance.Stations.ToList());

                if (station == null)
                {
                    MessageBox.Show("There are no stations before 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);
            }
        }