Microsoft.Xna.Framework.Audio.SoundEffectInstance.Play C# (CSharp) Méthode

Play() public méthode

Plays or resumes a SoundEffectInstance.
Throws an exception if more sounds are playing than the platform allows.
public Play ( ) : void
Résultat void
        public void Play()
        {
            if (State == SoundState.Playing)
                return;

            // We don't need to check if we're at the instance play limit
            // if we're resuming from a paused state.
            if (State != SoundState.Paused)
            {
                SoundEffectInstancePool.Remove(this);

                if (!SoundEffectInstancePool.SoundsAvailable)
                    throw new InstancePlayLimitException();
            }
            
            // For non-XAct sounds we need to be sure the latest
            // master volume level is applied before playback.
            if (!_isXAct)
                PlatformSetVolume(_volume * SoundEffect.MasterVolume);

            PlatformPlay();
        }

Usage Example

        public void Update(GameManager gameManager, Menu menu, Carte map)
        {
            if (nouveaujeu == false && gameManager.Etat == GameManager.etat.NouveauJeuIntro)
            {
                sonmanager.Stop();
                sonmanager = sons[5].CreateInstance();
                sonmanager.IsLooped = true;
                sonmanager.Play();
                nouveaujeu = true;
            }

            if (jeu == false && gameManager.Etat == GameManager.etat.InGame)
            {
                jeu = true;
            }

            if (!menu.pauseactive)
            {
                if (menu.sound == Menu.Son.On && sonmanager.State == SoundState.Paused)
                {
                    sonmanager.Play();
                }

                if (menu.sound == Menu.Son.Off && sonmanager.State == SoundState.Playing)
                {
                    sonmanager.Pause();
                }
            }

            if(menu.pauseactive)
            {
                if (sonmanager.State == SoundState.Playing)
                    sonmanager.Pause();
            }
        }
All Usage Examples Of Microsoft.Xna.Framework.Audio.SoundEffectInstance::Play