예제 #1
0
        /// <summary>
        /// Циклический разматывание очереди сообщений.
        /// Сообщение тоже раскладывается на items и проигрывается плеером каждый item.
        /// </summary>
        private async Task CycleInvoke()
        {
            while (!_cts.IsCancellationRequested)
            {
                SoundMessage message;
                if (Queue.TryDequeue(out message))
                {
                    PlayingMessage = message;
                    SoundMessageChangeRx.OnNext(new SoundMessageChangeRx
                    {
                        StatusPlaying = StatusPlaying.Start,
                        SoundMessage  = PlayingMessage
                    });
                    while (PlayingMessage.QueueItems.Any())
                    {
                        var soundItem = PlayingMessage.QueueItems.Dequeue();
                        Debug.WriteLine($"Start >>>>>>>>  {DateTime.Now:T}   {soundItem.FileName}");
                        var res = await _player.PlayFile(soundItem, _cts.Token);

                        Debug.WriteLine($"End <<<<<<<<   {DateTime.Now:T}    {soundItem.FileName}");
                        await Task.Delay(soundItem.PauseTime ?? 0, _cts.Token);
                    }
                    PlayedMessage  = PlayingMessage;
                    PlayingMessage = null;
                    SoundMessageChangeRx.OnNext(new SoundMessageChangeRx
                    {
                        StatusPlaying = StatusPlaying.Stop,
                        SoundMessage  = PlayedMessage
                    });
                }
            }
        }
예제 #2
0
        public void Play(string file)
        {
            if (!File.Exists(file))
            {
                console.Error($"File {file} doesn't exist.");
                return;
            }

            soundPlayer.PlayFile(file);
        }
예제 #3
0
        public void Initialize()
        {
            GameLog.Client.General.InfoFormat("Initializing... !");
            RegisterViewsAndServices();
            RegisterEventHandlers();
            RegisterCommandHandlers();
            UpdateCommands();

            UIHelpers.IsAutomaticBrowserLaunchEnabled = true;

            if (AutoLoadSavedGame())
            {
                return;
            }

            _navigationCommands.ActivateScreen.Execute(StandardGameScreens.MenuScreen);
            GameLog.Client.General.InfoFormat("MenuScreen activated... ");
            _soundPlayer.PlayFile("Resources/SoundFX/MenuScreen.ogg");
        }
예제 #4
0
 private void OnTurnStarted(ClientEventArgs e)
 {
     _soundPlayer.PlayFile("Resources/SoundFX/NewTurn.ogg");
 }