Ejemplo n.º 1
0
        /// <summary>
        /// Play or resume the current sound instance with extended parameters.
        /// </summary>
        /// <param name="stopSiblingInstances">Indicate if the sibling instances should be stopped or not</param>
        protected void PlayExtended(bool stopSiblingInstances)
        {
            CheckNotDisposed();

            if (EngineState == AudioEngineState.Invalidated)
            {
                return;
            }

            if (AudioEngine.State == AudioEngineState.Paused) // drop the call to play if the audio engine is paused.
            {
                return;
            }

            if (PlayState == SoundPlayState.Playing)
            {
                return;
            }

            if (stopSiblingInstances)
            {
                StopConcurrentInstances();
            }

            if (!DataBufferLoaded)
            {
                LoadBuffer();
            }

            PlayImpl();

            DataBufferLoaded = true;

            PlayState = SoundPlayState.Playing;
        }
Ejemplo n.º 2
0
 public void Resume()
 {
     if (state == SoundPlayState.Pause)
     {
         StartCoroutine(m_coroutineMethod);
         state = SoundPlayState.Playing;
         source.UnPause();
     }
 }
Ejemplo n.º 3
0
 public void Pause()
 {
     if (state == SoundPlayState.Playing || state == SoundPlayState.DelayWait)
     {
         StopCoroutine(m_coroutineMethod);
         state = SoundPlayState.Pause;
         source.Pause();
     }
 }
Ejemplo n.º 4
0
        public void Stop()
        {
            playState = SoundPlayState.Stopped;

            foreach (var instance in associatedSoundEffectInstances)
            {
                instance.Stop();
            }
            ShouldBePlayed = false;
        }
Ejemplo n.º 5
0
 public void Stop()
 {
     if (state == SoundPlayState.DelayWait || state == SoundPlayState.Playing || state == SoundPlayState.Pause)
     {
         source.Stop();
         StopCoroutine(m_coroutineMethod);
         state = SoundPlayState.Stop;
         gameObject.SetActive(false);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 初期化
 /// </summary>
 public void Init()
 {
     state    = SoundPlayState.Stop;
     m_source = this.gameObject.AddComponent <AudioSource>();
     m_source.outputAudioMixerGroup = SimpleSoundManager.Instance.seAudioMixerGroup;
     source.loop        = false;
     source.playOnAwake = false;
     m_waitTimeCnt      = 0.0f;
     ResetPlayer();
 }
Ejemplo n.º 7
0
    private IEnumerator _Play()
    {
        if (!isLoopInfinity)
        {
            loopCount--;
        }

        //delay wait.
        m_waitTimeCnt = 0.0f;
        while (m_waitTimeCnt < delay)
        {
            m_waitTimeCnt += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        //start callback
        if (onStart != null)
        {
            onStart.Invoke();
        }

        state = SoundPlayState.Playing;
        source.Play();


        m_waitTimeCnt = 0.0f;
        while (m_waitTimeCnt < source.clip.length / source.pitch)
        {
            m_waitTimeCnt += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }


        if (onComplete != null)
        {
            onComplete.Invoke();
        }


        //終わるかのチェック
        if (loopCount <= 0)
        {
            state = SoundPlayState.Stop;
            PlayEnd();
            m_coroutineMethod = null;
            yield break;
        }
        else
        {
            m_coroutineMethod = _Play();
            StartCoroutine(m_coroutineMethod);
            yield break;
        }
    }
Ejemplo n.º 8
0
        public void Stop()
        {
            playState = SoundPlayState.Stopped;

            foreach (var instance in InstanceToListener)
            {
                instance.Key.Stop();
            }

            ShouldBePlayed = false;
        }
Ejemplo n.º 9
0
 public void Init()
 {
     m_state      = SoundPlayState.Stop;
     m_fadeVolume = 1.0f;
     m_source     = this.gameObject.AddComponent <AudioSource>();
     m_source.outputAudioMixerGroup = SimpleSoundManager.Instance.bgmAudioMixerGroup;
     m_source.playOnAwake           = false;
     m_source.loop         = false;
     m_source.spatialBlend = 0.0f;
     m_source.volume       = SimpleSoundManager.Instance.volumeBgm;
 }
Ejemplo n.º 10
0
        public void Play()
        {
            playState = SoundPlayState.Playing;

            // Controller play function is asynchronous.
            // underlying sound instances actually start playing only after the next system update.
            // Such a asynchronous behavior is required in order to be able to update the associated AudioEmitter
            // and apply localization to the sound before starting to play.

            ShouldBePlayed = true;  // tells the EmitterProcessor to start playing the underlying instances.
        }
Ejemplo n.º 11
0
        public void Play()
        {
            if (SoundPlayState.eSS_Pause == m_playState)
            {
                m_audio.UnPause();
            }
            else
            {
                m_audio.Play(m_delay);
            }

            m_playState = SoundPlayState.eSS_Play;
        }
        private async void ButtonOnPlayStateChanged(
            SoundPlayButton activeButton, SoundPlayState newState)
        {
            lock (_lockObject)
            {
                if (_isLoading)
                {
                    return;
                }
                _isLoading = true;
            }

            if (activeButton == null)
            {
                return;
            }
            _activeButton = activeButton;

            var notification = new SoundPlayStateChangedNotification
            {
                NewSound = (Sound)activeButton.DataContext,
                NewState = newState
            };

            if (newState == SoundPlayState.Playing)
            {
                foreach (SoundPlayButton button in _buttons)
                {
                    if (button != activeButton &&
                        button.State == SoundPlayState.Playing)
                    {
                        button.State = SoundPlayState.Stopped;
                        MediaElementSound.Stop();
                    }
                }

                await SetSound(activeButton.Sound);

                Play();
            }
            else
            {
                activeButton.State = SoundPlayState.Paused;
                Stop();
            }

            //if (Command != null)
            //    Command.Execute(notification);

            _isLoading = false;
        }
Ejemplo n.º 13
0
    /// <summary>
    /// 再生する
    /// </summary>
    public void Play()
    {
        gameObject.SetActive(true);
        state         = SoundPlayState.DelayWait;
        source.volume = volume;
        source.pitch  = pitch;

        if (onStartBefore != null)
        {
            onStartBefore.Invoke();
        }

        m_coroutineMethod = _Play();
        StartCoroutine(m_coroutineMethod);
    }
Ejemplo n.º 14
0
        public void Pause()
        {
            if (PlayState != SoundPlayState.Playing)
            {
                return;
            }

            playState = SoundPlayState.Paused;

            foreach (var instance in associatedSoundEffectInstances)
            {
                instance.Pause();
            }
            ShouldBePlayed = false;
        }
Ejemplo n.º 15
0
        public void Pause()
        {
            if (PlayState != SoundPlayState.Playing)
            {
                return;
            }

            playState = SoundPlayState.Paused;

            foreach (var instance in InstanceToListener)
            {
                instance.Key.Pause();
            }

            ShouldBePlayed = false;
        }
        private void ChangeSoundStateChanged(SoundPlayState newState)
        {
            var oldState = _activeButton.State;

            _activeButton.State = newState;

            var notification = new SoundPlayStateChangedNotification
            {
                OldSound = _sound,
                OldState = oldState,
                NewSound = _sound,
                NewState = newState
            };

            //if (Command != null)
            //    Command.Execute(notification);
        }
Ejemplo n.º 17
0
    public void Pause()
    {
        if (!(m_state == SoundPlayState.Playing || m_state == SoundPlayState.DelayWait))
        {
            return;
        }

        m_beforeState = m_state;
        m_state       = SoundPlayState.Pause;
        StopCoroutine(m_playMethod);
        m_source.Pause();

        if (isFade)
        {
            StopCoroutine(m_fadeMethod);
        }
    }
Ejemplo n.º 18
0
    public void Resume()
    {
        //ポーズ中ではない時は処理しない
        if (m_state != SoundPlayState.Pause)
        {
            return;
        }

        m_state = m_beforeState;
        StartCoroutine(m_playMethod);
        m_source.Play();

        if (isFade)
        {
            StartCoroutine(m_fadeMethod);
        }
    }
Ejemplo n.º 19
0
    public void Stop()
    {
        if (m_playMethod != null)
        {
            StopCoroutine(m_playMethod);
            m_playMethod = null;
        }

        m_source.Stop();
        m_state = SoundPlayState.Stop;

        if (isFade)
        {
            StopCoroutine(m_fadeMethod);
            m_fadeMethod = null;
        }
    }
Ejemplo n.º 20
0
        private bool SoundStop()
        {
            if (!IsActive)
            {
                return(true);
            }

            lock (mSoundObj)
            {
                if (PlayState != SoundPlayState.NOSOUND)
                {
                    mSoundPlayer.Stop();
                    PlayState = SoundPlayState.NOSOUND;
                }
                return(true);
            }
        }
Ejemplo n.º 21
0
        public virtual void Pause()
        {
            CheckNotDisposed();

            if (EngineState == AudioEngineState.Invalidated)
            {
                return;
            }

            if (PlayState != SoundPlayState.Playing)
            {
                return;
            }

            PauseImpl();

            PlayState = SoundPlayState.Paused;
        }
Ejemplo n.º 22
0
        public virtual void Stop()
        {
            CheckNotDisposed();

            if (EngineState == AudioEngineState.Invalidated)
            {
                return;
            }

            if (PlayState == SoundPlayState.Stopped)
            {
                return;
            }

            StopImpl();

            DataBufferLoaded = false;

            PlayState = SoundPlayState.Stopped;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Play or resume the current sound instance with extended parameters.
        /// </summary>
        /// <param name="stopSiblingInstances">Indicate if the sibling instances should be stopped or not</param>
        protected void PlayExtended(bool stopSiblingInstances)
        {
            CheckNotDisposed();

            if (EngineState == AudioEngineState.Invalidated)
                return;

            if (AudioEngine.State == AudioEngineState.Paused) // drop the call to play if the audio engine is paused.
                return;

            if (PlayState == SoundPlayState.Playing)
                return;

            if (stopSiblingInstances)
                StopConcurrentInstances();

            if (!DataBufferLoaded)
                LoadBuffer();

            PlayImpl();

            DataBufferLoaded = true;

            PlayState = SoundPlayState.Playing;
        }
Ejemplo n.º 24
0
        private bool SoundPlay(IVisionAlarm alarm)
        {
            if (!IsActive)
            {
                return(false);
            }

            lock (mSoundObj)
            {
                ISoundActionConfig config = Config as ISoundActionConfig;

                if (alarm == null || config == null || config.IsMute)
                {
                    return(false);                                                  //静音
                }
                if (alarm.EventType == TVisionEventType.Perimeter)
                {
                    if (alarm.GuardLevel == TGuardLevel.Red)
                    {
                        if (PlayState != SoundPlayState.ALARMPLAYING)//当前未发报警音
                        {
                            if (PlayState != SoundPlayState.NOSOUND)
                            {
                                mSoundPlayer.Stop();
                            }

                            try
                            {
                                mSoundPlayer.SoundLocation = config.AlarmSoundFile;
                                mSoundPlayer.LoadAsync();

                                if (!IsMute)
                                {
                                    mSoundPlayer.PlayLooping();
                                }

                                PlayState = SoundPlayState.ALARMPLAYING;
                                return(true);
                            }
                            catch
                            {
                                System.Console.Out.Write("找不到报警声音文件");
                            }
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else if (alarm.GuardLevel == TGuardLevel.Prompt)
                    {
                        if (PlayState != SoundPlayState.PORMATPLAYING)//当前未发提示音
                        {
                            if (PlayState != SoundPlayState.NOSOUND)
                            {
                                mSoundPlayer.Stop();
                            }

                            try
                            {
                                mSoundPlayer.SoundLocation = config.PormatSoundFile;
                                mSoundPlayer.LoadAsync();

                                if (!IsMute)
                                {
                                    mSoundPlayer.Play();//仅一次
                                }
                                //mSoundPlayer.PlayLooping();
                                PlayState = SoundPlayState.NOSOUND;
                                return(true);
                            }
                            catch
                            {
                                System.Console.Out.Write("找不到提示声音文件");
                            }
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                else if (alarm.EventType == TVisionEventType.Leave || alarm.EventType == TVisionEventType.Remove)
                {
                    if (PlayState != SoundPlayState.ALARMPLAYING)//当前未发报警音
                    {
                        if (PlayState != SoundPlayState.NOSOUND)
                        {
                            mSoundPlayer.Stop();
                        }

                        try
                        {
                            mSoundPlayer.SoundLocation = config.AlarmSoundFile;
                            mSoundPlayer.LoadAsync();

                            if (!IsMute)
                            {
                                mSoundPlayer.PlayLooping();
                            }

                            PlayState = SoundPlayState.ALARMPLAYING;
                            return(true);
                        }
                        catch
                        {
                            System.Console.Out.Write("找不到报警声音文件");
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                else if (alarm.EventType == TVisionEventType.CameraUnusual)
                {
                    if (PlayState != SoundPlayState.CAMABOUT)//当前未发报警音
                    {
                        if (PlayState != SoundPlayState.NOSOUND)
                        {
                            mSoundPlayer.Stop();
                        }
                        try
                        {
                            mSoundPlayer.SoundLocation = config.CamaboutSoundFile;
                            mSoundPlayer.LoadAsync();
                            if (!IsMute)
                            {
                                mSoundPlayer.PlayLooping();
                            }

                            PlayState = SoundPlayState.CAMABOUT;
                            return(true);
                        }
                        catch
                        {
                            System.Console.Out.Write("找不到镜头异常声音文件");
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                PlayState = SoundPlayState.NOSOUND;
                return(false);
            }
        }
Ejemplo n.º 25
0
 public void ResetPlayer()
 {
     gameObject.SetActive(false);
     state = SoundPlayState.Stop;
 }
Ejemplo n.º 26
0
        public virtual void Stop()
        {
            CheckNotDisposed();

            if (EngineState == AudioEngineState.Invalidated)
                return;

            if (PlayState == SoundPlayState.Stopped)
                return;

            StopImpl();

            DataBufferLoaded = false;

            PlayState = SoundPlayState.Stopped;
        }
Ejemplo n.º 27
0
    private IEnumerator _Play()
    {
        m_state       = SoundPlayState.DelayWait;
        m_waitTimeCnt = 0.0f;
        while (m_waitTimeCnt < delay)
        {
            m_waitTimeCnt += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        //状態をプレイ中に変更
        m_state = SoundPlayState.Playing;

        //イントロの曲があるかのチェック
        if (introClip != null)
        {
            //イントロ開始
            if (onIntroStart != null)
            {
                onIntroStart.Invoke();
            }

            m_source.time = 0.0f;
            m_source.clip = introClip;
            ChangeVolume();
            m_source.Play();
            m_state       = SoundPlayState.Playing;
            m_waitTimeCnt = 0.0f;
            while (m_waitTimeCnt < introClip.length)
            {
                m_waitTimeCnt += Time.deltaTime;
                yield return(new WaitForEndOfFrame());
            }

            //イントロ終了
            if (onIntroComplete != null)
            {
                onIntroComplete.Invoke();
            }
        }

        //メインBGM
        do
        {
            //メイン開始
            if (onMainStart != null)
            {
                onMainStart.Invoke();
            }

            m_source.clip = m_mainClip;
            m_source.time = 0.0f;

            ChangeVolume();
            m_source.Play();

            m_waitTimeCnt = 0.0f;
            while (m_waitTimeCnt < m_mainClip.length)
            {
                m_waitTimeCnt += Time.deltaTime;
                yield return(new WaitForEndOfFrame());
            }

            if (!isLoop)
            {
                m_state = SoundPlayState.Stop;
            }

            //メイン終了
            if (onMainComplete != null)
            {
                onMainComplete.Invoke();
            }
        } while (isLoop);

        m_playMethod = null;
    }
Ejemplo n.º 28
0
 public void Stop()
 {
     m_playState = SoundPlayState.eSS_Stop;
     m_audio.Stop();
 }
        private void ChangeSoundStateChanged(SoundPlayState newState)
        {
            var oldState = _activeButton.State;
            _activeButton.State = newState;

            var notification = new SoundPlayStateChangedNotification
            {
                OldSound = _sound,
                OldState = oldState,
                NewSound = _sound,
                NewState = newState
            };

            //if (Command != null)
            //    Command.Execute(notification);
        }
Ejemplo n.º 30
0
 public void Pause()
 {
     m_playState = SoundPlayState.eSS_Pause;
     m_audio.Pause();
 }
Ejemplo n.º 31
0
        public void Play()
        {
            if (SoundPlayState.eSS_Pause == m_playState)
            {
                m_audio.UnPause();
            }
            else
            {
                m_audio.Play(m_delay);
            }

            m_playState = SoundPlayState.eSS_Play;
        }
        public void Stop()
        {
            playState = SoundPlayState.Stopped;

            foreach (var instance in InstanceToListener)
            {
                instance.Key.Stop();
            }

            ShouldBePlayed = false;
        }
        public void Pause()
        {
            if (PlayState != SoundPlayState.Playing)
                return;

            playState = SoundPlayState.Paused;

            foreach (var instance in InstanceToListener)
            {
                instance.Key.Pause();
            }

            ShouldBePlayed = false;
        }
Ejemplo n.º 34
0
 public void Stop()
 {
     m_playState = SoundPlayState.eSS_Stop;
     m_audio.Stop();
 }
Ejemplo n.º 35
0
        public virtual void Pause()
        {
            CheckNotDisposed();

            if (EngineState == AudioEngineState.Invalidated)
                return;

            if(PlayState != SoundPlayState.Playing)
                return; 

            PauseImpl();

            PlayState = SoundPlayState.Paused;
        }
Ejemplo n.º 36
0
 public void Pause()
 {
     m_playState = SoundPlayState.eSS_Pause;
     m_audio.Pause();
 }
Ejemplo n.º 37
0
 public bool bInCurState(SoundPlayState state)
 {
     return(m_playState == state);
 }
        public void Pause()
        {
            if (PlayState != SoundPlayState.Playing)
                return;

            playState = SoundPlayState.Paused;

            foreach (var instance in associatedSoundEffectInstances)
            {
                instance.Pause();
            }
            ShouldBePlayed = false;
        }
        private async void ButtonOnPlayStateChanged(
            SoundPlayButton activeButton, SoundPlayState newState)
        {
            lock (_lockObject)
            {
                if (_isLoading) return;
                _isLoading = true;
            }

            if (activeButton == null) return;
            _activeButton = activeButton;

            var notification = new SoundPlayStateChangedNotification
            {
                NewSound = (Sound)activeButton.DataContext,
                NewState = newState
            };

            if (newState == SoundPlayState.Playing)
            {
                foreach (SoundPlayButton button in _buttons)
                {
                    if (button != activeButton &&
                        button.State == SoundPlayState.Playing)
                    {
                        button.State = SoundPlayState.Stopped;
                        MediaElementSound.Stop();
                    }
                }

                await SetSound(activeButton.Sound);
                Play();
            }
            else
            {
                activeButton.State = SoundPlayState.Paused;
                Stop();
            }

            //if (Command != null)
            //    Command.Execute(notification);

            _isLoading = false;
        }
Ejemplo n.º 40
0
 public bool bInCurState(SoundPlayState state)
 {
     return m_playState == state;
 }
        public void Play()
        {
            playState = SoundPlayState.Playing;

            // Controller play function is asynchronous.
            // underlying sound instances actually start playing only after the next system update.
            // Such a asynchronous behavior is required in order to be able to update the associated AudioEmitter
            // and apply localization to the sound before starting to play.

            ShouldBePlayed = true;  // tells the EmitterProcessor to start playing the underlying instances.
        }
        public void Stop()
        {
            playState = SoundPlayState.Stopped;

            foreach (var instance in associatedSoundEffectInstances)
            {
                instance.Stop();
            }
            ShouldBePlayed = false;
        }