BalloonsPop.SoundPlayer.SoundsPlayer.PlaySound C# (CSharp) Method

PlaySound() public method

Plays the sound matching the given string. If no matching sound, throw an exception.
public PlaySound ( string soundName ) : void
soundName string
return void
        public void PlaySound(string soundName)
        {
            try
            {
                if (!this.sounds.ContainsKey(soundName))
                {
                    this.RegisterSound(soundName, this.loader.CreateSoundMedia(soundName));
                }

                var player = this.sounds[soundName];
                player.Play();
            }
            catch (Exception ex)
            {
                Logger.Warn("Cannot load media file.", ex);
            }
        }