IEnumerator WaitForStop(string audio)
 {
     FMOD.Studio.PLAYBACK_STATE state;
     instance.getPlaybackState(out state);
     instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     while (state != FMOD.Studio.PLAYBACK_STATE.STOPPED)
     {
         instance.getPlaybackState(out state);
         yield return(null);
     }
     Play(audio);
     yield return(null);
 }
Esempio n. 2
0
        void Update()
        {
            if (isSpeaking)
            {
                if (eventInstance.isValid())
                {
                    FMOD.Studio.PLAYBACK_STATE playbackState;
                    eventInstance.getPlaybackState(out playbackState);

                    if (playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED)
                    {
                        eventInstance.release();

                        if (!coroutineRunning)
                        {
                            isSpeaking = false;
                        }
                        if (!string.IsNullOrEmpty(currentDialogue) && !coroutineRunning)
                        {
                            string latestDialogue = currentDialogue;
                            currentDialogue = null;

                            if (voiceoverManager != null)
                            {
                                voiceoverManager.ReportSpeakerAvailability(speaker, latestDialogue);
                            }
                        }
                    }
                }
                else if (!coroutineRunning)
                {
                    isSpeaking = false;
                }
            }
        }
 public bool IsPlaying()
 {
     if (instance.isValid())
     {
         FMOD.Studio.PLAYBACK_STATE playbackState;
         instance.getPlaybackState(out playbackState);
         return(playbackState != FMOD.Studio.PLAYBACK_STATE.STOPPED);
     }
     return(false);
 }
Esempio n. 4
0
 void Update()
 {
     if (instance != null)
     {
         instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, cachedRigidBody));
         FMOD.Studio.PLAYBACK_STATE state;
         instance.getPlaybackState(out state);
         if (state == FMOD.Studio.PLAYBACK_STATE.STOPPED)
         {
             instance.release();
             instance = null;
             enabled  = false;
         }
     }
 }
Esempio n. 5
0
        private void HandlePlay(FMODEvent ambientSFX)
        {
            //Is there AmbientSFX currently playing?
            FMOD.Studio.PLAYBACK_STATE playbackState;
            CurrentAmbientSFX.getPlaybackState(out playbackState);
            bool isPlaying = playbackState != FMOD.Studio.PLAYBACK_STATE.STOPPED;

            //If so, wind down the old SFX, then switch in the new FMOD Event
            if (string.IsNullOrEmpty(ambientSFX.Name))
            {
                HandleStop();
            }
            else if (isPlaying)
            {
                //If it's not the same FMOD Event, then switch over
                if (GetInstantiatedEventName(CurrentAmbientSFX) != ambientSFX.Name)
                {
                    HandleStop();
                    CurrentAmbientSFX = FMODUnity.RuntimeManager.CreateInstance(ambientSFX.Name);
                    //Handle all the parameters
                    foreach (FMODEventParameterConfig param in ambientSFX.Parameters)
                    {
                        CurrentAmbientSFX.setParameterValue(param.Name, param.Value);
                    }
                    //Actually start the FMOD Event
                    CurrentAmbientSFX.start();
                }
                //If it is the same track, just adjust the parameters
                else
                {
                    foreach (FMODEventParameterConfig param in ambientSFX.Parameters)
                    {
                        CurrentAmbientSFX.setParameterValue(param.Name, param.Value);
                    }
                }
            }
            else
            {
                CurrentAmbientSFX = FMODUnity.RuntimeManager.CreateInstance(ambientSFX.Name);
                CurrentAmbientSFX.start();
            }
        }