Exemplo n.º 1
0
 void PlatformDispose(bool disposing)
 {
     if (_audioData != IntPtr.Zero)
     {
         SdlMixer.Mix_FreeMusic(_audioData);
     }
 }
Exemplo n.º 2
0
        public void FreeMusic()
        {
            InitAudio();
            IntPtr wavPtr = Sdl.SDL_RWFromFile("test.wav", "rb");

            SdlMixer.Mix_FreeMusic(wavPtr);
            QuitAudio();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Triggered when the background music has stopped processing.
        /// </summary>
        private void OnMusicEnded()
        {
            // Unallocate our music
            SdlMixer.Mix_FreeMusic(musicChunk);

            // Start up some new music
            PlayMusic("Background");
        }
Exemplo n.º 4
0
        private void Dispose(bool disposing)
        {
            SdlMixer.Mix_FreeMusic(music);

            //if (string.IsNullOrEmpty(tempfile) == false)
            //{
            //    File.Delete(tempfile);
            //    tempfile = "";
            //}
        }
Exemplo n.º 5
0
        /// <summary>
        /// Internal function that processes the play request as a music
        /// file and not a sound element.
        /// </summary>
        /// <param name="key"></param>
        private void PlayMusic(string key)
        {
            // See if we have the category
            if (!categories.Contains(key))
            {
                // No music, no effect
                Debug("No music for {0}", key);
                return;
            }

            // If the category is empty, remove it
            if (categories[key].Count == 0)
            {
                // Remove the category and return
                categories.Remove(key);
                return;
            }

            // Get the random song key
            FileInfo file  = categories[key].GetRandomSound();
            string   sound = file.FullName;

            Debug("Playing music: {0}", sound);
            musicChunk = SdlMixer.Mix_LoadMUS(sound);

            // Start playing the music
            int result = -1;

            try
            {
                result = SdlMixer.Mix_PlayMusic(musicChunk, 1);
            }
            catch (Exception e)
            {
                Error("Can't play music: {0}", e.Message);
            }

            if (result == -1)
            {
                // Remove the chunk
                SdlMixer.Mix_FreeMusic(musicChunk);
                categories[key].Remove(file);

                // Find a new one
                PlayMusic(key);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Closes Music handle
 /// </summary>
 protected override void CloseHandle()
 {
     try
     {
         if (this.Handle != IntPtr.Zero)
         {
             SdlMixer.Mix_FreeMusic(this.Handle);
             this.Handle = IntPtr.Zero;
         }
     }
     catch (NullReferenceException)
     {
     }
     catch (AccessViolationException)
     {
     }
     finally
     {
         this.Handle = IntPtr.Zero;
     }
 }
Exemplo n.º 7
0
 ///< Frees the memory used by SdlMixer.
 public void unload()//not being called yet.
 {
     SdlMixer.Mix_FreeMusic(handle);
 }