Beispiel #1
0
        public void SetMusic(string se, bool looping)
        {
            float volume = game.settings.musVolume;

            if (game.settings.mutedMusic)
            {
                volume = 0;
            }
            if (File.Exists(game.Content.RootDirectory + game.PathSeperator + "Music" + game.PathSeperator + se + ".ogg"))
            {
                if (currentMusic == se)
                {
                    return;
                }
                currentMusic = se;
                if (music != null)
                {
                    music.Stop();
                }
            }
            else
            {
                currentMusic = "";
                music.Stop();
                Console.WriteLine("PANIC: MUSIC FILE " + se + " NOT FOUND");
                return;
            }
            if (se != currentMusic || music == null)
            {
                if (music != null)
                {
                    music.Stop();
                    music.Dispose();
                    music = null;
                }
                music          = new OggStream(game.Content.RootDirectory + game.PathSeperator + "Music" + game.PathSeperator + se + ".ogg");
                music.IsLooped = looping;
                music.Volume   = volume;
                music.Play();
                currentMusic = se;
            }
            else
            {
                if (music.IsFinished())
                {
                    music.Stop();
                    music.Dispose();
                    music          = null;
                    music          = new OggStream(game.Content.RootDirectory + game.PathSeperator + "Music" + game.PathSeperator + se + ".ogg");
                    music.IsLooped = looping;
                    music.Volume   = volume;
                    music.Play();
                    currentMusic = se;
                }
            }
        }
Beispiel #2
0
        void PlatformDispose(bool disposing)
        {
            if (stream == null)
            {
                return;
            }

            stream.Dispose();
            stream = null;
        }
Beispiel #3
0
        public void Dispose()
        {
            if (_stream == null)
            {
                return;
            }

            Stop();
            _stream.Dispose();
            _stream = null;
        }
Beispiel #4
0
        void PlatformDispose(bool disposing)
        {
            lock (_sourceMutex)
            {
                if (stream == null)
                {
                    return;
                }

                stream.Dispose();
                stream = null;
            }
        }
Beispiel #5
0
        internal Song(string name, string file, AudioFormat format = AudioFormat.Ogg)
        {
            if (format != AudioFormat.Ogg)
            {
                throw new NotImplementedException("Support for formats other than ogg is not yet implemented.");
            }

            _name = name;
            _file = file;

            try
            {
                _stream = new OggStream(_file);
                _stream.Prepare();
            }
            catch (InvalidDataException)
            {
                _stream.Dispose();
                _stream = new OggStream(_file);
                _stream.Prepare();
            }
        }
Beispiel #6
0
 void PlatformDispose(bool disposing)
 {
     stream.Dispose();
 }