Пример #1
0
        public Sound(string filename, bool loop)
        {
            if (String.IsNullOrEmpty(filename))
            {
                return;
            }

            mFilename = GameContentManager.RemoveExtension(filename).ToLower();
            mLoop     = loop;
            var sound = Globals.ContentManager.GetSound(mFilename);

            if (sound != null)
            {
                mSound           = sound.CreateInstance();
                mSound.IsLooping = mLoop;
                mSound.SetVolume(Globals.Database.SoundVolume);
                mSound.Play();
                Loaded = true;
            }
        }
        private static void StartMusic(string filename, float fadein = 0f, bool loop = false)
        {
            var music = Globals.ContentManager.GetMusic(filename);

            if (music == null)
            {
                return;
            }

            if (sMyMusic != null)
            {
                Log.Warn($"Trying to start '{filename}' without properly closing '{sCurrentSong}'.");
            }

            sMyMusic     = music.CreateInstance();
            sCurrentSong = filename;
            sMyMusic.Play();
            sMyMusic.SetVolume(0, true);
            sMyMusic.IsLooping = loop;
            sFadeRate          = (float)100 / fadein;
            sFadeTimer         = Globals.System.GetTimeMs() + (long)(sFadeRate / 1000) + 1;
            sFadingOut         = false;
        }