private void SetIcon()
        {
            switch (Interaction.Icon)
            {
            case MessageIcon.Error:
                _soundPlayer.Play(SystemSounds.Hand);
                break;

            case MessageIcon.Exclamation:
                _soundPlayer.Play(SystemSounds.Exclamation);
                break;

            case MessageIcon.Info:
                _soundPlayer.Play(SystemSounds.Asterisk);
                break;

            case MessageIcon.Question:
                _soundPlayer.Play(SystemSounds.Question);
                break;

            case MessageIcon.Warning:
                _soundPlayer.Play(SystemSounds.Exclamation);
                break;

            case MessageIcon.PDFCreator:
                IconSize = 45;
                break;

            case MessageIcon.PDFForge:
                IconSize = 45;
                break;
            }

            RaisePropertyChanged(nameof(IconSize));
        }
        internal async Task <MessageResult> PlayFile(string file)
        {
            var messageResult = new MessageResult();

            if (!File.Exists(file))
            {
                messageResult.Message = "文件不存在:" + file;
                return(messageResult);
            }

            try
            {
                await _soundPlayer.Play(file);

                messageResult.Success = true;
                messageResult.Message = "OK";
                messageResult.Data    = file;
                return(messageResult);
            }
            catch (Exception e)
            {
                messageResult.Message = e.Message;
                return(messageResult);
            }
        }
Beispiel #3
0
 protected override void HandleInteractionObjectChanged()
 {
     if (Interaction.ShowViewerWarning)
     {
         _soundPlayer.Play(SystemSounds.Hand);
     }
 }
    public override void Perform(InputAction.CallbackContext context)
    {
        //instansiates projectile with player rotation, so it can just fly forward
        GameObject Projectile = Instantiate(ProjectilePrefab, Gun.transform.position, gameObject.transform.rotation);

        Projectile.transform.parent = null;
        SoundPlayer.Play(Sounds.Fire);
    }
 protected override void HandleInteractionObjectChanged()
 {
     if (Interaction.ShowViewerWarning)
     {
         _soundPlayer.Play(SystemSounds.Hand);
     }
     RaisePropertyChanged(nameof(RecommendedText));
     RaisePropertyChanged(nameof(ErrorText));
 }
        public bool Play(int soundId, float offset)
        {
            if (soundId > (int)EVehicleSoundId.Invalid)
            {
                //mute other sounds
                MuteSoundExcept(soundId);

                // if it is the first time audio-play then create the specified sound entity.
                SoundEntity soundEntity = null;
                if (!_soundEntityCache.ContainsKey(soundId))
                {
                    soundEntity = CreateSoundEntity(soundId);
                    _soundEntityCache[soundId] = soundEntity;
                }

                soundEntity = _soundEntityCache[soundId];
                if (soundEntity == null)
                {
                    return(true);
                }

                //play the speicified sound
                if (soundEntity.hasAudioSourceKey)
                {
                    var soundKey = soundEntity.audioSourceKey.Value;
                    if (_soundPlayer.IsPlaying(soundKey))
                    {
                        _soundPlayer.Mute(soundKey, false);
                    }
                    else
                    {
                        var isLoopSound = _soundConfigManager.IsLoopSound(soundId);
                        if (isLoopSound && offset > 0)
                        {
                            var clipLength = _soundPlayer.GetLength(soundKey);
                            if (clipLength > 0)
                            {
                                offset %= clipLength;
                            }
                        }
                        _soundPlayer.Play(soundKey, offset, isLoopSound);
                    }

                    return(true);
                }

                return(false);
            }

            //mute all sound if try play Invalid Sound
            MuteSoundExcept((int)EVehicleSoundId.Invalid);

            return(true);
        }
Beispiel #7
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     DebrisCreator?.Create();
     SoundPlayer.Play(DestructionSound);
     //начисление очков за сбитого врага
     if (collision.gameObject.CompareTag("Player"))
     {
         PlayerScore += Info.ScoreToGain;
     }
     //процедура уничтожения астероида
     Instantiate(DestructionEffect, gameObject.transform.position, Quaternion.identity);
     Destroy(gameObject);
 }
Beispiel #8
0
        private void SendCommand(string command)
        {
            lock (thisLock)
            {
                var data = generator.Generate(command);
#if DEBUG
                //var text =ByteArrayToString(data);
                //initiate self-destruct sequence
                //Console.WriteLine(text);
#endif
                player.Play(data);
            }
        }
Beispiel #9
0
 public void PlaySounds(string[] soundFiles, EventHandler playingFinishedCallback)
 {
     CodeContract.Requires(soundFiles != null && soundFiles.Length > 0);
     if (_soundFiles != null)
     {
         _soundPlayer.Stop();
     }
     else if (!QuietMode)
     {
         ProcessHelper.ExecCommand(_config.Commands.BeforePlaying);
     }
     _soundFiles              = soundFiles;
     _currentSoundFileIndex   = 0;
     _playingFinishedCallback = playingFinishedCallback;
     if (QuietMode)
     {
         _playingFinishedCallback.RaiseEvent(this);
     }
     else
     {
         _soundPlayer.Play(_soundFiles[0]);
     }
 }
Beispiel #10
0
        public void OnGamePlay()
        {
            foreach (SoundEntity soundEntity in _group)
            {
                var key = soundEntity.audioSourceKey.Value;
                if (!soundEntity.flagPlaying && _currentTime.CurrentTime > soundEntity.timeInfo.StartTime)
                {
                    if (null == soundEntity.unityObj.UnityObject)
                    {
                        Logger.Error("sound entity's unityobj is null");
                        soundEntity.isFlagDestroy = true;
                        continue;
                    }

                    if (soundEntity.hasPosition)
                    {
                        soundEntity.unityObj.UnityObject.AsGameObject.transform.position = soundEntity.position.Value;
                    }

                    if (soundEntity.hasSoundPlayInfo)
                    {
                        _soundPlayer.Play(key, soundEntity.soundPlayInfo.Loop);
                    }
                    else
                    {
                        _soundPlayer.Play(key);
                    }
                    _playList.Add(soundEntity);
                }
            }

            foreach (var soundEntity in _playList)
            {
                soundEntity.flagPlaying = true;
            }
            _playList.Clear();
        }
    private IEnumerator Fire()
    {
        Vector3 Target = PlayerPosition.Get();

        RotateGun(Target);
        //instansiates projectile with player rotation, so it can just fly forward
        GameObject Projectile = Instantiate(ProjectilePrefab, Gun.transform.position, Gun.transform.rotation);

        Projectile.transform.parent = null;
        SoundPlayer.Play(Sounds.Fire);
        yield return(new WaitForSeconds(Settings.MaxFireInterval));

        GetFireInterval();
        StartCoroutine(Fire());
    }
Beispiel #12
0
        /// <summary>
        /// Plays the caution sound. The sound is repeated at the configured interval.
        /// </summary>
        public void CautionThresholdReached()
        {
            var count = 0;

            timer = new Timer(
                callback: new TimerCallback(o =>
            {
                if (count++ < Repeat)
                {
                    player.Play();
                }
            }),
                state: null,
                dueTime: 0,
                period: Interval);
        }
Beispiel #13
0
        private void PlaySound()
        {
            if (soundService == null)
            {
                soundService = ServiceLocator.GetSoundPlayer();
            }

            if (Properties.Settings.Default.UseCustomSound)
            {
                soundService.SoundFile = new Uri(Properties.Settings.Default.BreakSoundFile);
            }
            else
            {
                soundService.SoundFile = new Uri(new FileInfo("DefaultSound.wav").FullName);
            }

            soundService.Play(track_workDurationCompletedCount);
        }
Beispiel #14
0
        void CivSelector_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (!_startAudio)
            {
                _startAudio = true;
                return;
            }
            if (CivSelector.SelectedIndex >= 0)
            {
                switch (CivSelector.SelectedValue.ToString())
                {
                case "Federation":
                    _soundPlayer.Play("Menu", "FedSelection");
                    break;

                case "Terran Empire":
                    _soundPlayer.Play("Menu", "TerranSelection");
                    break;

                case "Romulans":
                    _soundPlayer.Play("Menu", "RomSelection");
                    break;

                case "Klingons":
                    _soundPlayer.Play("Menu", "KlingSelection");
                    break;

                case "Cardassians":
                    _soundPlayer.Play("Menu", "CardSelection");
                    break;

                case "Dominion":
                    _soundPlayer.Play("Menu", "DomSelection");
                    break;

                case "Borg":
                    _soundPlayer.Play("Menu", "BorgSelection");
                    break;
                }
            }
        }
Beispiel #15
0
        private void lnkPlaySound_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // TODO: Test for file existence
            // TODO: Test for exceptions
            // TODO: Run sound playing in a different thread
            // TODO: Provider way to stop the sound from playing.
            // TODO: Avoid issue where person presses play button and causes io exception as another process is using the wav file.

            if (_soundPlayer == null)
            {
                _soundPlayer = ServiceLocator.GetSoundPlayer();
                _soundPlayer.SoundPlaybackEnded += new SoundPlaybackEnded(SoundPlayer_PlaybackEnded);
            }

            if (_soundPlayer.IsPlaybackEnded)
            {
                if (cbUseCustomSound.Checked)
                {
                    _soundPlayer.SoundFile =
                        new Uri(new FileInfo(txtBreakSound.Text).FullName);
                }
                else
                {
                    // Kudos: DefaultSound  http://www.freesound.org/samplesViewSingle.php?id=118648
                    _soundPlayer.SoundFile =
                        new Uri(new FileInfo("DefaultSound.wav").FullName);
                }

                _soundPlayer.Play();
                lnkPlaySound.Text = "Stop Sound";
            }
            else
            {
                StopPlayingSound();
            }
        }
Beispiel #16
0
 /// <summary>
 /// Плей плеера
 /// </summary>
 /// <returns>если плеер поставленн на плей то true</returns>
 public bool PlayPlayer()
 {
     _player.Play();
     return(GetPlayerStatus == SoundPlayerStatus.Playing);
 }
Beispiel #17
0
 public IPlayingSoundContext Play(string prm)
 {
     return(m_Player.Play(prm));
 }
Beispiel #18
0
 //в системе ввода настроена реакция на нажатие и отпускание кнопки.
 //в этом случае событие performed срабатывает 2 раза: при нажатии кнопки и отпускании.
 //следовательно все время, пока кнопка нажата, в методе Update производится вращение игрока в направлении,
 //переданном из контекста.
 public override void Perform(InputAction.CallbackContext context)
 {
     ButtonIsPressed = !ButtonIsPressed;
     ThrustAnimator.SetBool(AnimatorBoolName, ButtonIsPressed);
     SoundPlayer.Play(Sounds.Thrust, true);
 }
Beispiel #19
0
 public void Play(ISoundPlayer player)
 {
     // TODO: add some kind of reference to the playing sound
     player.Play(_data);
 }
Beispiel #20
0
 public void PlayOneShot(string prm)
 {
     m_Player.Play(prm);
 }
 public void Play(ISoundPlayer soundPlayer)
 {
     soundPlayer.Play(this._sourceEffectInstance);
 }