public override void PlayMusic(Music music) { if (music != this.music) { this.music = music; if (music != null) { SDL_mixer.Mix_VolumeMusic(musicVolume); SDL_mixer.Mix_PlayMusic(music.GetChunk(), -1); Logger.Info("Sound", $"Playing music {music}"); } else { SDL_mixer.Mix_HaltMusic(); } } }
public static void Main() { int audio_rate = 44100; ushort audio_format = SDL.AUDIO_S16SYS; int audio_channels = 2; int audio_buffers = 4096; int audio_volume = SDL_mixer.MIX_MAX_VOLUME; int timeleft = 50; SDL.SDL_Init(SDL.SDL_INIT_AUDIO); if (SDL_mixer.Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) { return; } else { SDL_mixer.Mix_QuerySpec(out audio_rate, out audio_format, out audio_channels); } SDL_mixer.Mix_AllocateChannels(32); SDL_mixer.Mix_VolumeMusic(audio_volume / 3); System.IntPtr music = SDL_mixer.Mix_LoadMUS("Tetris_theme.ogg"); System.IntPtr wave = SDL_mixer.Mix_LoadWAV("Meow.ogg"); SDL_mixer.Mix_FadeInMusic(music, 1, 2000); while (SDL_mixer.Mix_PlayingMusic() != 0) { SDL.SDL_Delay(100); timeleft--; if (timeleft == 0) { break; } if (timeleft == 25) { SDL_mixer.Mix_PlayChannel(-1, wave, 0); } } SDL_mixer.Mix_FadeOutMusic(2000); SDL_mixer.Mix_FreeMusic(music); SDL_mixer.Mix_FreeChunk(wave); SDL.SDL_Delay(500); SDL_mixer.Mix_CloseAudio(); SDL.SDL_Quit(); }
internal static void ReglerVolumeMusique(int volume) { SDL_mixer.Mix_VolumeMusic(volume); }
protected override void SetMusicVolume(int volume) { SDL_mixer.Mix_VolumeMusic(volume); }
private void LoadAndPlayMusic() { MusicPointer = SDL_mixer.Mix_LoadMUS(MusicFilePath); SDL_mixer.Mix_FadeInMusic(MusicPointer.Value, -1, 1000); SDL_mixer.Mix_VolumeMusic(MusicVolume); }