/// <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; }
public void Resume() { if (state == SoundPlayState.Pause) { StartCoroutine(m_coroutineMethod); state = SoundPlayState.Playing; source.UnPause(); } }
public void Pause() { if (state == SoundPlayState.Playing || state == SoundPlayState.DelayWait) { StopCoroutine(m_coroutineMethod); state = SoundPlayState.Pause; source.Pause(); } }
public void Stop() { playState = SoundPlayState.Stopped; foreach (var instance in associatedSoundEffectInstances) { instance.Stop(); } ShouldBePlayed = false; }
public void Stop() { if (state == SoundPlayState.DelayWait || state == SoundPlayState.Playing || state == SoundPlayState.Pause) { source.Stop(); StopCoroutine(m_coroutineMethod); state = SoundPlayState.Stop; gameObject.SetActive(false); } }
/// <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(); }
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; } }
public void Stop() { playState = SoundPlayState.Stopped; foreach (var instance in InstanceToListener) { instance.Key.Stop(); } ShouldBePlayed = false; }
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; }
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 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; }
/// <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); }
public void Pause() { if (PlayState != SoundPlayState.Playing) { return; } playState = SoundPlayState.Paused; foreach (var instance in associatedSoundEffectInstances) { instance.Pause(); } ShouldBePlayed = false; }
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); }
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); } }
public void Resume() { //ポーズ中ではない時は処理しない if (m_state != SoundPlayState.Pause) { return; } m_state = m_beforeState; StartCoroutine(m_playMethod); m_source.Play(); if (isFade) { StartCoroutine(m_fadeMethod); } }
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; } }
private bool SoundStop() { if (!IsActive) { return(true); } lock (mSoundObj) { if (PlayState != SoundPlayState.NOSOUND) { mSoundPlayer.Stop(); PlayState = SoundPlayState.NOSOUND; } return(true); } }
public virtual void Pause() { CheckNotDisposed(); if (EngineState == AudioEngineState.Invalidated) { return; } if (PlayState != SoundPlayState.Playing) { return; } PauseImpl(); PlayState = SoundPlayState.Paused; }
public virtual void Stop() { CheckNotDisposed(); if (EngineState == AudioEngineState.Invalidated) { return; } if (PlayState == SoundPlayState.Stopped) { return; } StopImpl(); DataBufferLoaded = false; PlayState = SoundPlayState.Stopped; }
/// <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; }
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); } }
public void ResetPlayer() { gameObject.SetActive(false); state = SoundPlayState.Stop; }
public virtual void Stop() { CheckNotDisposed(); if (EngineState == AudioEngineState.Invalidated) return; if (PlayState == SoundPlayState.Stopped) return; StopImpl(); DataBufferLoaded = false; PlayState = SoundPlayState.Stopped; }
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; }
public void Stop() { m_playState = SoundPlayState.eSS_Stop; m_audio.Stop(); }
public void Pause() { m_playState = SoundPlayState.eSS_Pause; m_audio.Pause(); }
public void Pause() { if (PlayState != SoundPlayState.Playing) return; playState = SoundPlayState.Paused; foreach (var instance in InstanceToListener) { instance.Key.Pause(); } ShouldBePlayed = false; }
public virtual void Pause() { CheckNotDisposed(); if (EngineState == AudioEngineState.Invalidated) return; if(PlayState != SoundPlayState.Playing) return; PauseImpl(); PlayState = SoundPlayState.Paused; }
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; }
public bool bInCurState(SoundPlayState state) { return m_playState == state; }