void PlatformDispose(bool disposing) { if (_audioData != IntPtr.Zero) { SdlMixer.Mix_FreeMusic(_audioData); } }
public void FreeMusic() { InitAudio(); IntPtr wavPtr = Sdl.SDL_RWFromFile("test.wav", "rb"); SdlMixer.Mix_FreeMusic(wavPtr); QuitAudio(); }
/// <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"); }
private void Dispose(bool disposing) { SdlMixer.Mix_FreeMusic(music); //if (string.IsNullOrEmpty(tempfile) == false) //{ // File.Delete(tempfile); // tempfile = ""; //} }
/// <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); } }
/// <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; } }
///< Frees the memory used by SdlMixer. public void unload()//not being called yet. { SdlMixer.Mix_FreeMusic(handle); }