Exemplo n.º 1
0
        public static void PlayExtraSound(string FileName, bool Looped = false)
        {
            if (!(E_Types.Options.Sound == 1) || !File.Exists(Application.StartupPath + E_Globals.SOUND_PATH + FileName))
            {
                return;
            }
            //If FileName = CurExtraSound Then Exit Sub

            SoundBuffer buffer = default(SoundBuffer);

            if (ReferenceEquals(ExtraSoundPlayer, null))
            {
                ExtraSoundPlayer             = new Sound();
                buffer                       = new SoundBuffer(Application.StartupPath + E_Globals.SOUND_PATH + FileName);
                ExtraSoundPlayer.SoundBuffer = buffer;
                if (Looped == true)
                {
                    ExtraSoundPlayer.Loop = true;
                }
                else
                {
                    ExtraSoundPlayer.Loop = false;
                }
                ExtraSoundPlayer.Volume = MaxVolume;
                ExtraSoundPlayer.Play();
            }
            else
            {
                ExtraSoundPlayer.Stop();
                buffer = new SoundBuffer(Application.StartupPath + E_Globals.SOUND_PATH + FileName);
                ExtraSoundPlayer.SoundBuffer = buffer;
                if (Looped == true)
                {
                    ExtraSoundPlayer.Loop = true;
                }
                else
                {
                    ExtraSoundPlayer.Loop = false;
                }
                ExtraSoundPlayer.Volume = MaxVolume;
                ExtraSoundPlayer.Play();
            }
        }
Exemplo n.º 2
0
        public static void PlayExtraSound(string fileName, bool looped = false)
        {
            if (C_Types.Options.Sound == 0 || !File.Exists(Application.StartupPath + C_Constants.SoundPath + fileName))
            {
                return;
            }

            SoundBuffer buffer = default(SoundBuffer);

            if (ReferenceEquals(ExtraSoundPlayer, null))
            {
                ExtraSoundPlayer             = new Sound();
                buffer                       = new SoundBuffer(Application.StartupPath + C_Constants.SoundPath + fileName);
                ExtraSoundPlayer.SoundBuffer = buffer;
                if (looped == true)
                {
                    ExtraSoundPlayer.Loop = true;
                }
                else
                {
                    ExtraSoundPlayer.Loop = false;
                }
                ExtraSoundPlayer.Volume = MaxVolume;
                ExtraSoundPlayer.Play();
            }
            else
            {
                ExtraSoundPlayer.Stop();
                buffer = new SoundBuffer(Application.StartupPath + C_Constants.SoundPath + fileName);
                ExtraSoundPlayer.SoundBuffer = buffer;
                if (looped == true)
                {
                    ExtraSoundPlayer.Loop = true;
                }
                else
                {
                    ExtraSoundPlayer.Loop = false;
                }
                ExtraSoundPlayer.Volume = MaxVolume;
                ExtraSoundPlayer.Play();
            }
        }
Exemplo n.º 3
0
        public static void PlayWeatherSound(string fileName, bool looped = false)
        {
            if (!(C_Types.Options.Sound == 1) || !File.Exists(Application.StartupPath + C_Constants.SoundPath + fileName))
            {
                return;
            }
            if (CurWeatherMusic == fileName)
            {
                return;
            }

            SoundBuffer buffer = default(SoundBuffer);

            if (ReferenceEquals(WeatherSoundPlayer, null))
            {
                WeatherSoundPlayer = new Sound();
            }
            else
            {
                WeatherSoundPlayer.Stop();
            }

            buffer = new SoundBuffer(Application.StartupPath + C_Constants.SoundPath + fileName);
            WeatherSoundPlayer.SoundBuffer = buffer;
            if (looped == true)
            {
                WeatherSoundPlayer.Loop = true;
            }
            else
            {
                WeatherSoundPlayer.Loop = false;
            }
            WeatherSoundPlayer.Volume = C_Sound.MaxVolume;
            WeatherSoundPlayer.Play();

            CurWeatherMusic = fileName;
        }