public void ChangeRS(Channels channel)
    {
        int currentIndex = 0;

        for (int i = 0; i < rS.Length; i++)
        {
            if (channel == rS[i].channelName)
            {
                currentIndex = i;
                break;
            }
            if (i == rS.Length - 1)
            {
                //no match

                channel = Channels.None;
            }
        }
        switch (channel)
        {
        case Channels.None:
            audioSource.Stop();
            RadioText.text = "None";
            break;

        default:
            currentRsIndex = currentIndex;
            currentRS      = rS[currentIndex];
            RadioText.text = currentRS.channelNameText.ToString();
            SetAudio();
            break;
        }
    }
        public async Task <IEnumerable <PodcastShow> > GetLatestPodcastsAsync(RadioStation radioStation, int count = 0)
        {
            if (radioStation == null)
            {
                throw new ArgumentNullException(nameof(radioStation));
            }

            try
            {
                var uri = new Uri(radioStation.PodcastsUrl);

                using var client = new HttpClient();

                var archivePageContent = await client.GetStringAsync(uri).ConfigureAwait(false);

                var xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(archivePageContent);

                return(xmlDocument.HasChildNodes
                            ? ParsePodcasts(xmlDocument.DocumentElement?.SelectSingleNode("channel"))
                            : Enumerable.Empty <PodcastShow>());
            }
            catch (XmlException xmlEx)
            {
                _logger?.LogError(xmlEx, $"Error getting latest podcasts from RTVS: {xmlEx.Message}");

                return(Enumerable.Empty <PodcastShow>());
            }
            catch (HttpRequestException hrEx)
            {
                _logger?.LogError(hrEx, $"Error getting latest podcasts from RTVS: {hrEx.Message}");

                return(Enumerable.Empty <PodcastShow>());
            }
        }
        public static async void PlayRadio(RadioStation station)
        {
            AudioService.Playlist.Clear();

            try
            {
                _currentRadio = station;
                if (!string.IsNullOrEmpty(_sessionId))
                {
                    //удаляем предыдущую сессию, чтобы не засорять Echonest (и потому что есть ограничение в 1000 сессий)
                    await DeleteSession(_sessionId);
                }

                if (station.Songs == null)
                {
                    await CreateArtistsSession(station.Artists.Select(s => s.Name));
                }
                else
                {
                    await CreateSongsSession(station.Songs.Select(s => s.Id));
                }


                if (_futureSongs != null && _futureSongs.Count > 0)
                {
                    AudioService.SetCurrentPlaylist(new List <Audio>(), true);

                    PlaySong(_futureSongs.First());
                }
            }
            catch (Exception ex)
            {
                LoggingService.Log(ex);
            }
        }
Example #4
0
        public async Task <bool> DeleteFavorite(RadioStation station)
        {
            if (!Application.Current.Properties.ContainsKey("key"))
            {
                return(false);
            }
            var favorite = Mapper.Map(station);

            string             apiUrl  = string.Format("https://{0}/api/favorite/{1}", databaseAPIIP, Application.Current.Properties["key"]);
            Uri                uri     = new Uri(string.Format(apiUrl, string.Empty));
            HttpRequestMessage request = new HttpRequestMessage
            {
                Method     = HttpMethod.Delete,
                RequestUri = uri,
                Content    = new StringContent(JsonConvert.SerializeObject(favorite), Encoding.UTF8, "application/json")
            };
            var response = await client.SendAsync(request).ConfigureAwait(false);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                var success = JsonConvert.DeserializeObject <bool>(content);

                return(success);
            }
            return(false);
        }
Example #5
0
        public async void StartRadioStation()
        {
            using (var service = CreateCollectionSqlService())
            {
                _station = await service.SelectFirstAsync <RadioStation>(p => p.Id == RadioId);

                if (_station == null)
                {
                    return;
                }

                // Create the station manager
                var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id,
                                                                  CreateCollectionSqlService,
                                                                  CreatePlayerSqlService);

                // Load tracks and add them to the database
                await radioStationManager.LoadTracksAsync();

                await radioStationManager.UpdateQueueAsync();

                OnEvent(QueueUpdated);

                _appSettingsHelper.Write(PlayerConstants.CurrentTrack, radioStationManager.QueueSongs[0].Id);
                StartRadioTrack(radioStationManager.QueueSongs[0]);
            }
        }
Example #6
0
        public void TestPlayPauseFunctionOutput()
        {
            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                RadioStation   rs1 = new RadioStation("98 FM", "Music", new FmFrequencyBand(104.4, null));
                RadioPlayerApp rpa = new RadioPlayerApp();
                rpa.Add(rs1);
                rpa.Play(rs1.stationName);

                string expectedPlay = string.Format("Playing station {0}", rs1.stationName);
                Assert.AreEqual <string>(expectedPlay, sw.ToString().Remove(sw.ToString().Length - 2));
                sw.Close();
            }

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                RadioStation   rs1 = new RadioStation("98 FM", "Music", new FmFrequencyBand(104.4, null));
                RadioPlayerApp rpa = new RadioPlayerApp();
                rpa.Add(rs1);
                rpa.Pause(rs1.stationName);
                string expectedPause = string.Format("Pausing station {0}", rs1.stationName);
                Assert.AreEqual <string>(expectedPause, sw.ToString().Remove(sw.ToString().Length - 2));
                sw.Close();
            }
        }
        private void TrvRadioStations_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var trv = sender as TreeView;

            if (trv.SelectedItem is TreeViewItem)
            {
                TreeViewItem selectedItem = trv.SelectedItem as TreeViewItem;

                if (selectedItem.Tag is RadioStation radio)
                {
                    this._currentRadio          = radio;
                    this.btnEditRadio.IsEnabled = true;
                    ChangeRadioStation(this._currentRadio);
                }

                if (!isTreeViewItemMoving)
                {
                    int index = this.trvRadioStations.Items.IndexOf(selectedItem);

                    if (index == this.trvRadioStations.Items.Count - 1)
                    {
                        this.btnDown.IsEnabled = false;
                    }
                    else if (index == 0)
                    {
                        this.btnUp.IsEnabled = false;
                    }
                    else
                    {
                        this.btnDown.IsEnabled = true;
                        this.btnUp.IsEnabled   = true;
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Adds the radio stations to the database.
        /// </summary>
        /// <param name="station">The radio station.</param>
        /// <param name="stations">Multiple radio stations.</param>
        /// <returns>A task.</returns>
        public async Task AddStations(RadioStation station = null, IEnumerable <RadioStation> stations = null)
        {
            if (stations == null)
            {
                stations = new List <RadioStation>();
            }
            else
            {
                stations = stations.ToList();
            }

            if (station != null)
            {
                ((List <RadioStation>)stations).Add(station);
            }

            if (stations.Count() > 0)
            {
                using (var db = new Db())
                {
                    string[] urls     = stations.Select(s => s.Url.ToLower()).ToArray();
                    var      existing = await db.RadioStations.Where(s => urls.Contains(s.Url.ToLower())).ToListAsync();

                    stations = stations.Where(s => !existing.Any(es => es.Url.ToLower() == s.Url.ToLower())).ToList();
                    db.RadioStations.AddRange(stations);
                    await db.SaveChangesAsync();
                }
            }
        }
Example #9
0
        public Task <IEnumerable <Track> > GetLatestTracksAsync(RadioStation radioStation, int count = 0)
        {
            if (radioStation == null)
            {
                throw new ArgumentNullException(nameof(radioStation));
            }

            return(Task.Factory.StartNew(() =>
            {
                try
                {
                    var document = new XmlDocument();
                    document.Load(radioStation.PlaylistUrl);

                    return document.HasChildNodes
                            ? ParseTracks(document)
                            : Enumerable.Empty <Track>();
                }
                catch (XmlException xmlEx)
                {
                    _logger.LogError(xmlEx, $"Error getting latest tracks in playlist from {radioStation.Name}: {xmlEx.Message}");

                    return Enumerable.Empty <Track>();
                }
            }));
        }
Example #10
0
    public void OnGotButton()
    {
        if (PlayerStatus.IsTodaySigned())
        {
            return;
        }
        var day  = PlayerStatus.sign + 1;
        var gold = GetGoldOfDay(day);

        PlayerStatus.gold += gold;
        PlayerStatus.sign += 1;
        SetLastSignDayAsToday();
        PlayerStatus.Save();

        if (selectItem1 != null)
        {
            selectItem1.Flash();
            selectItem1.IsGot = true;
        }
        if (selectItem2 != null)
        {
            selectItem2.Flash();
            selectItem2.IsGot = true;
        }

        button_got.interactable = false;
        var text = button_got.GetComponentInChildren <Text>();

        text.text  = "已领取";
        text.color = new Color(1f, 1f, 1f, 0.7f);
        AudioManager.PlaySe("gain-gold");
        CoroutineManager.Create(WaitAndBack());
        RadioStation.Brodcast("SIGN");
    }
        private void InitializeTreeViewRadioStations(Profile profile)
        {
            if (this.trvRadioStations.Items.Count != 0)
            {
                this.trvRadioStations.Items.Clear();
            }

            foreach (RadioStation radio in profile.RadioStations)
            {
                AddRadioNodeToTreeView(radio);
            }

            if (this.trvRadioStations.Items.Count > 0)
            {
                if (!string.IsNullOrEmpty(profile.LastRadioId))
                {
                    foreach (TreeViewItem item in this.trvRadioStations.Items)
                    {
                        if (item.Tag is RadioStation itemRadio && itemRadio.Id == profile.LastRadioId)
                        {
                            _currentRadio   = itemRadio;
                            item.IsSelected = true;
                            ChangeRadioStation(_currentRadio);
                        }
                    }
                }
                else
                {
                    if (this.trvRadioStations.Items[0] is TreeViewItem firstRadio)
                    {
                        firstRadio.IsSelected = true;
                    }
                }
            }
        }
Example #12
0
        private void BtnRemove_Click(object sender, RoutedEventArgs e)
        {
            TreeViewItem itemToDelete  = this.trvRadioStations.SelectedItem as TreeViewItem;
            RadioStation radioToDelete = itemToDelete.Tag as RadioStation;

            if (itemToDelete != null && radioToDelete != null)
            {
                string       message = "Do you really want to delete " + radioToDelete.Name + " from your collection?";
                const string caption = "Radio Station removal";
                if (MessageBox.Show(message, caption, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    try
                    {
                        _profile.RadioStations.Remove(radioToDelete);
                        TreeViewItem parent = itemToDelete.Parent as TreeViewItem;
                        int          index  = parent.Items.IndexOf(itemToDelete);
                        parent.Items.RemoveAt(index);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Example #13
0
        public async Task <IEnumerable <Track> > GetLatestTracksAsync(RadioStation radioStation, int count = 0)
        {
            if (radioStation == null)
            {
                throw new ArgumentNullException(nameof(radioStation));
            }

            var htmlTracks = await GetHtmlPlaylistTracks(radioStation.PlaylistUrl);

            if (htmlTracks == null)
            {
                return(Enumerable.Empty <Track>());
            }

            // process tracks
            var tracks = new List <Track>();

            foreach (var trackNode in htmlTracks)
            {
                var tds = trackNode.ChildNodes
                          .Where(node => node.Name == "td")
                          .ToList();

                if (tds.Count != 4)
                {
                    continue;
                }

                tracks.Add(CreateTrack(tds));
            }

            return(tracks);
        }
        public async Task <IEnumerable <ScheduleItem> > GetFullScheduleAsync(RadioStation radioStation)
        {
            if (radioStation == null)
            {
                throw new ArgumentNullException(nameof(radioStation));
            }

            try
            {
                var uri = new Uri(radioStation.ScheduleUrl);

                using var client = new HttpClient();

                var schedulePageContent = await client.GetStringAsync(uri).ConfigureAwait(false);

                var xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(schedulePageContent);

                return(xmlDocument.HasChildNodes
                            ? ParseScheduleItems(xmlDocument)
                            : Enumerable.Empty <ScheduleItem>());
            }
            catch (XmlException xmlEx)
            {
                _logger?.LogError(xmlEx, $"Error getting full schedule for {radioStation.Name} from RTVS: {xmlEx.Message}");

                return(Enumerable.Empty <ScheduleItem>());
            }
            catch (HttpRequestException hrEx)
            {
                _logger?.LogError(hrEx, $"Error getting full schedule for {radioStation.Name} from RTVS: {hrEx.Message}");

                return(Enumerable.Empty <ScheduleItem>());
            }
        }
        public void DoesntHandleNullObjectsCorrectly()
        {
            var subject   = new SportsAggregator();
            var observer1 = new NewsPaper();
            var observer2 = new RadioStation();

            subject.RegisterObserver(observer1);
            subject.RegisterObserver(observer2);
            observer1 = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            var gameResult = new GameResult
            {
                GameDate     = DateTime.Now,
                LosingScore  = 1,
                LosingTeam   = "Chicago Cubs",
                WinningScore = 5,
                WinningTeam  = "Cincinnati Reds"
            };

            subject.AddGameResult(gameResult);
            subject.UnregisterObserver(observer2);
            //subject.UnregisterObserver(observer1);
            Assert.Equal(1, subject.Observers.Count);
        }
Example #16
0
        public void FillWithSampleData()
        {
            RadioStation trojka = new RadioStation("Trójka", "http://*****:*****@"C:\Users\kburdzinski\Documents\Visual Studio 2013\Projects\adkiller\adkiller\adkiller\Data\Jingle\startJingleTrojka48.mp3", @"C:\Users\kburdzinski\Documents\Visual Studio 2013\Projects\adkiller\adkiller\adkiller\Data\Jingle\endJingleTrojka48.mp3", 10);

            this.ConfigurationName = "Polskie radia";
            this.Stations.Add(trojka);
        }
Example #17
0
    public Audiance()
    {
        radioStation    = RadioStation.allStations[0];
        id              = id_sequence++;
        PreferedGaners  = new List <AudianceGanerPrefernce>();
        ArtistPrefernce = new List <AudianceArtistPrefernce>();
        PreferedSongs   = new List <AudianceSongPrefernce>();
        pateince        = S.random.Next(S.MIN_ABILITY_VALUE, S.MAX_ABILITY_VALUE);
        extremism       = S.random.Next(S.MIN_ABILITY_VALUE, S.MAX_ABILITY_VALUE);
        IQ              = S.random.Next(S.MIN_ABILITY_VALUE, S.MAX_ABILITY_VALUE);
        age             = S.random.Next(10, 70);
        pateince        = S.random.Next(S.MIN_ABILITY_VALUE, S.MAX_ABILITY_VALUE);
        gender          = S.random.Next(1, 2) % 2 == 1 ? 'M' : 'F';
        name            = "RAZ SAMUEL";
        foreach (musicGaner m in Enum.GetValues(typeof(musicGaner)))
        {
            PreferedGaners.Add(new AudianceGanerPrefernce(m));
        }

        foreach (Artists artist in Artists.allArtists)
        {
            ArtistPrefernce.Add(new AudianceArtistPrefernce(artist));
        }
        foreach (Songs song in Songs.allSongs)
        {
            PreferedSongs.Add(new AudianceSongPrefernce(song));
        }

        radioStation.audianceList.Add(this);
    }
Example #18
0
    void OnItemClicked(PictruePage_Item item)
    {
        AudioManager.PlaySe("button");
        // 如果是图片分类,则开始新游戏
        //if(!isUncomplete)
        //{
        if (item.data.status != PicturePage_ItemStatus.Locked)
        {
            //UIEngine.Forward<LevelCompletePage>();
            var picId = item.data.picRow.Get <int>("id");
            // GameController.EnterCore(picId);
            var admin = new Admission_PopupNewPage();
            UIEngine.Forward <LevelSettingsPage>(picId.ToString(), admin);
        }
        RadioStation.Brodcast("SELECT_PIC");
        //}

        // 如果是未完成的拼图, 则继续游戏
        // if(isUncomplete)
        // {
        //     var picId = item.data.picRow.Get<int>("id");
        //     var info = PlayerStatus.uncompletePuzzle[picId.ToString()];
        //     GameController.EnterWithInfo(info);
        //     // GameController.EnterCore(picId);
        //     // var admin = new Admission_PopupNewPage();
        //     // UIEngine.Forward<LevelSettingsPage>(picId.ToString(), admin);
        // }
    }
Example #19
0
        public void SportsAggregator_AddGameResult()
        {
            // Arrange
            var subject   = new SportsAggregator();
            var observer1 = new NewsPaper();
            var observer2 = new RadioStation();

            subject.RegisterObserver(observer1);
            subject.RegisterObserver(observer2);
            var gameResult = new GameResult
            {
                GameDate     = DateTime.Now,
                LosingScore  = 1,
                LosingTeam   = "Mariners",
                WinningScore = 10,
                WinningTeam  = "Astros"
            };

            // Action
            subject.AddGameResult(gameResult);

            // Assert
            Assert.AreEqual(1, observer1.Results.Count);
            Assert.AreEqual(1, observer2.Results.Count);
            Assert.AreSame(gameResult, observer1.Results[0]);
            Assert.AreSame(gameResult, observer2.Results[0]);

            // Action
            subject.UnregisterObserver(observer1);
            subject.UnregisterObserver(observer2);

            Assert.IsFalse(subject.Observers.Any());
        }
Example #20
0
            public void Update(RadioStation station)
            {
                Station           = station;
                Label.StringValue = station?.Name ?? "";

                ImageView.LoadFromItem(station);
            }
        private static void Main()
        {
            var radio = new RadioStation();

            var nSongs = int.Parse(Console.ReadLine().Trim());

            for (int i = 0; i < nSongs; i++)
            {
                try
                {
                    var songInfo = Console.ReadLine().Trim().Split(';');

                    var artistName = songInfo[0];
                    var songName   = songInfo[1];

                    var length = songInfo[2];

                    radio.AddSong(new Song(artistName, songName, length));
                }
                catch (RadioException re)
                {
                    Console.WriteLine(re.Message);
                }
            }

            Console.WriteLine(radio);
        }
Example #22
0
        public bool Equals(SimpleVariables other)
        {
            if (other == null)
            {
                return(false);
            }

            return(CurrentLevel.Equals(other.CurrentLevel) &&
                   CurrentArea.Equals(other.CurrentArea) &&
                   Language.Equals(other.Language) &&
                   MillisecondsPerGameMinute.Equals(other.MillisecondsPerGameMinute) &&
                   LastClockTick.Equals(other.LastClockTick) &&
                   GameClockHours.Equals(other.GameClockHours) &&
                   GameClockMinutes.Equals(other.GameClockMinutes) &&
                   GameClockSeconds.Equals(other.GameClockSeconds) &&
                   TimeInMilliseconds.Equals(other.TimeInMilliseconds) &&
                   TimeScale.Equals(other.TimeScale) &&
                   TimeStep.Equals(other.TimeStep) &&
                   TimeStepNonClipped.Equals(other.TimeStepNonClipped) &&
                   FramesPerUpdate.Equals(other.FramesPerUpdate) &&
                   FrameCounter.Equals(other.FrameCounter) &&
                   OldWeatherType.Equals(other.OldWeatherType) &&
                   NewWeatherType.Equals(other.NewWeatherType) &&
                   ForcedWeatherType.Equals(other.ForcedWeatherType) &&
                   WeatherTypeInList.Equals(other.WeatherTypeInList) &&
                   WeatherInterpolationValue.Equals(other.WeatherInterpolationValue) &&
                   CameraPosition.Equals(other.CameraPosition) &&
                   CameraModeInCar.Equals(other.CameraModeInCar) &&
                   CameraModeOnFoot.Equals(other.CameraModeOnFoot) &&
                   ExtraColor.Equals(other.ExtraColor) &&
                   IsExtraColorOn.Equals(other.IsExtraColorOn) &&
                   ExtraColorInterpolation.Equals(other.ExtraColorInterpolation) &&
                   Brightness.Equals(other.Brightness) &&
                   DisplayHud.Equals(other.DisplayHud) &&
                   ShowSubtitles.Equals(other.ShowSubtitles) &&
                   RadarMode.Equals(other.RadarMode) &&
                   BlurOn.Equals(other.BlurOn) &&
                   UseWideScreen.Equals(other.UseWideScreen) &&
                   MusicVolume.Equals(other.MusicVolume) &&
                   SfxVolume.Equals(other.SfxVolume) &&
                   RadioStation.Equals(other.RadioStation) &&
                   StereoOutput.Equals(other.StereoOutput) &&
                   PadMode.Equals(other.PadMode) &&
                   InvertLook.Equals(other.InvertLook) &&
                   UseVibration.Equals(other.UseVibration) &&
                   SwapNippleAndDPad.Equals(other.SwapNippleAndDPad) &&
                   HasPlayerCheated.Equals(other.HasPlayerCheated) &&
                   AllTaxisHaveNitro.Equals(other.AllTaxisHaveNitro) &&
                   TargetIsOn.Equals(other.TargetIsOn) &&
                   TargetPosition.Equals(other.TargetPosition) &&
                   PlayerPosition.Equals(other.PlayerPosition) &&
                   TrailsOn.Equals(other.TrailsOn) &&
                   TimeStamp.Equals(other.TimeStamp) &&
                   Unknown78hPS2.Equals(other.Unknown78hPS2) &&
                   Unknown7ChPS2.Equals(other.Unknown7ChPS2) &&
                   Unknown90hPS2.Equals(other.Unknown90hPS2) &&
                   UnknownB8hPSP.Equals(other.UnknownB8hPSP) &&
                   UnknownD8hPS2.Equals(other.UnknownD8hPS2) &&
                   UnknownD9hPS2.Equals(other.UnknownD9hPS2));
        }
Example #23
0
        private async void AddStation(IEnumerable <EchoArtist> artists)
        {
            var titleArtist = artists.First();

            var newStation = new RadioStation()
            {
                Artists = artists.ToList(),
                Title   = string.Join(", ", artists.Select(s => s.Name)),
            };

            Stations.Add(newStation);

            try
            {
                var artistImage = await DataService.GetArtistImage(titleArtist.Name, false);

                if (artistImage != null)
                {
                    newStation.ImageUrl = artistImage.OriginalString;
                }
            }
            catch (Exception ex)
            {
                LoggingService.Log(ex);
            }

            RadioService.SaveStations(Stations);
        }
Example #24
0
        public void ShouldHandleNullObjectsCorrectly()
        {
            var subject   = new SportsAggregatorWeakReferences();
            var observer1 = new NewsPaper();
            var observer2 = new RadioStation();
            var wr1       = subject.RegisterObserver(observer1);
            var wr2       = subject.RegisterObserver(observer2);

            observer1 = null;
            //Demo code. don't do this in real life
            GC.Collect();
            GC.WaitForPendingFinalizers();
            var gameResult = new GameResult
            {
                GameDate     = DateTime.Now,
                LosingScore  = 1,
                LosingTeam   = "Chicago Cubs",
                WinningScore = 5,
                WinningTeam  = "Cincinnati Reds"
            };

            subject.AddGameResult(gameResult);
            //No longer need this line...
            //subject.UnregisterObserver(wr1);
            foreach (var foo in subject.Observers)
            {
                foo?.TryGetTarget(out var observer);
            }
            subject.UnregisterObserver(wr2);
            Assert.Equal(0, subject.Observers.Count);
        }
Example #25
0
        public async Task Play(RadioStation station)
        {
            if (!await App.CheckForOffline())
            {
                return;
            }
            if (station == null)
            {
                App.ShowAlert(Strings.RenameError, Strings.PleaseTryAgain);
                return;
            }
            LogManager.Shared.LogPlay(station);
            var online = station as OnlineRadioStation;

            if (online != null)
            {
                await MusicManager.Shared.AddTemp(online);
            }
            SendEndNotification(ScrobbleManager.PlaybackEndedReason.Skipped);
            var context = new PlaybackContext
            {
                IsContinuous = true,
                Type         = PlaybackContext.PlaybackType.Radio,
                ParentId     = station.Id
            };

            if (context.ParentId != "IFL" && context.Equals(Settings.CurrentPlaybackContext) && CurrentPlaylistSongCount > 0)
            {
                Play();
                return;
            }

            using (new Spinner(Strings.StartingStation))
            {
                Settings.CurrentPlaybackContext = context;
                var success = await MusicManager.Shared.LoadRadioStationTracks(station);

                if (!success)
                {
                    App.ShowAlert(Strings.RenameError, Strings.PleaseTryAgain);
                    return;
                }
            }

            if (Settings.CurrentPlaybackContext?.ParentId != station.Id)
            {
                return;
            }

            await Task.Run(async() =>
            {
                string query = $"select SongId as Id from RadioStationSong where StationId = ? order by SOrder";
                await SetupCurrentPlaylist(query, "", new[] { station.Id });
            });

            var song = GetSong(CurrentSongIndex);
            await NativePlayer.PlaySong(song);

            await PrepareNextTrack();
        }
Example #26
0
    public void OnStartButton()
    {
        if (first)
        {
            return;
        }
        // 检查这个 picId 是否已经有存档,如果有则提示
        var picId = int.Parse(this.param as string);

        var info = PlayerStatus.TryGetUncompleteOfPicId(picId);

        if (info != null)
        {
            var param = new DialogParam();
            param.des    = "会覆盖已存在的游戏,是否继续?";
            param.button = "确定";
            var admin  = new Admission_PopupNewPage();
            var dialog = UIEngine.Forward <DialogPage>(param, admin);
            dialog.Complete = result => {
                if (result == DialogResult.Conform)
                {
                    GameController.EnterCore(picId, selectItem.dataRow.Get <int>("id"));
                }
            };
        }
        else
        {
            GameController.EnterCore(picId, selectItem.dataRow.Get <int>("id"));
        }
        AudioManager.PlaySe("button");
        RadioStation.Brodcast("NEW_GAME");
    }
        public void ShouldNotifyObserversOfGameResult()
        {
            var subject   = new SportsAggregator();
            var observer1 = new NewsPaper();
            var observer2 = new RadioStation();

            subject.RegisterObserver(observer1);
            subject.RegisterObserver(observer2);
            var gameResult = new GameResult
            {
                GameDate     = DateTime.Now,
                LosingScore  = 1,
                LosingTeam   = "Chicago Cubs",
                WinningScore = 5,
                WinningTeam  = "Cincinnati Reds"
            };

            subject.AddGameResult(gameResult);
            Assert.Equal(1, observer1.Results.Count);
            Assert.Equal(1, observer2.Results.Count);
            Assert.Same(gameResult, observer1.Results[0]);
            Assert.Same(gameResult, observer2.Results[0]);
            subject.UnregisterObserver(observer1);
            subject.UnregisterObserver(observer2);
            Assert.Equal(0, subject.Observers.Count);
        }
        protected override void DisplaySearchResultsInternal()
        {
            lvRadioStations.Items.Clear();

            if (this.Items != null)
            {
                foreach (var item in this.Items)
                {
                    RadioStation rs = item as RadioStation;
                    if (rs != null)
                    {
                        string title = rs.Title ?? string.Empty;

                        ListViewItem lvi = new ListViewItem(new string[] { "",

                                                                           title.ToUpperInvariant().StartsWith("TXT_") ?
                                                                           Translator.Translate(title) : title,

                                                                           rs.IsFake ? "" : rs.Source.ToString(),
                                                                           rs.Url, rs.Content, rs.Genre,
                                                                           rs.IsFake ? "" : rs.Bitrate.ToString(),
                                                                           rs.Type });

                        lvi.Tag = rs;
                        lvRadioStations.Items.Add(lvi);
                    }
                }

                if (lvRadioStations.Items.Count > 0)
                {
                    lvRadioStations.Items[0].Selected = true;
                    lvRadioStations.Items[0].Focused  = true;
                }
            }
        }
Example #29
0
        private void newStation_Click(object sender, EventArgs e)
        {
            string[]     station = Prompt.ShowDialog("Enter your radio stations' address", "New station", "Enter your radio stations' name");
            RadioStation st      = new RadioStation(station[0], "@\"" + station[1] + "\"");

            listBox1.Items.Add(station[1]);
            stations.Add(new RadioStation(station[1], station[0]));
        }
Example #30
0
 /// <summary>
 /// Updates an existing radio station.
 /// </summary>
 /// <param name="station">The radio station with the desired values.</param>
 /// <returns>A task.</returns>
 public async Task UpdateStation(RadioStation station)
 {
     using (var db = new Db())
     {
         db.Entry(station).State = EntityState.Modified;
         await db.SaveChangesAsync();
     }
 }
Example #31
0
        public void RadioStationsSetToRadioConfiguration()
        {
            var radio = new Mock<IRadio>();
            var radioConfiguration = new Mock<IRadioConfiguration>();
            radioConfiguration.SetupProperty(p => p.RadioStations);
            RadioWizardStep radioWizardStep = new RadioWizardStep(radio.Object, radioConfiguration.Object);
            RadioStation[] radioStations = new RadioStation[0];

            radioWizardStep.RadioStations = radioStations;

            Assert.AreEqual(radioStations, radioConfiguration.Object.RadioStations);
        }
 /// <summary>
 /// Given certain conditions.
 /// </summary>
 protected override void Given()
 {
     this.classUnderTest = new RadioStationMapper();
     this.input = new RadioStation { Name = "Radio", Country = new Country() { Name = "UK" } };
 }