Exemple #1
0
 public override void StopMusic()
 {
     if (music != null)
     {
         SDL_mixer.Mix_HaltMusic();
         music = null;
     }
 }
Exemple #2
0
 public void Stop(int channel = -1)
 {
     if (channel == MusicChannel)
     {
         SDL_mixer.Mix_HaltMusic();
     }
     else
     {
         SDL_mixer.Mix_HaltChannel(channel);
     }
 }
Exemple #3
0
 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();
         }
     }
 }
Exemple #4
0
        public void ToggleMusic()
        {
            if (UxConfig.MusicOn)
            {
                SDL_mixer.Mix_HaltMusic();
            }
            else
            {
                if (MusicPointer.HasValue)
                {
                    SDL_mixer.Mix_PlayMusic(MusicPointer.Value, -1);
                }
                else
                {
                    LoadAndPlayMusic();
                }
            }

            UxConfig.MusicOn = !UxConfig.MusicOn;
        }
Exemple #5
0
 internal static void ArreterJouerMusique()
 {
     SDL_mixer.Mix_HaltMusic();
 }
Exemple #6
0
 internal void Stop()
 {
     SDL_mixer.Mix_HookMusicFinished(null);
     SDL_mixer.Mix_HaltMusic();
     PlayCount = 0;
 }
Exemple #7
0
 public static void Halt()
 {
     Util.ThrowIfResultIsError(SDL_mixer.Mix_HaltMusic());
 }
Exemple #8
0
 public static void StopPlaying()
 {
     SDL_mixer.Mix_HaltMusic();
 }
Exemple #9
0
        static int Main(string[] args)
        {
            SDL.SDL_SetHint(SDL.SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;

            //Start up SDL and create window
            var success = Init();

            if (success == false)
            {
                Console.WriteLine("Failed to initialize!");
            }
            else
            {
                //Load media
                success = LoadMedia();
                if (success == false)
                {
                    Console.WriteLine("Failed to load media!");
                }
                else
                {
                    //Main loop flag
                    bool quit = false;

                    //While application is running
                    while (!quit)
                    {
                        //Event handler
                        SDL.SDL_Event e;

                        //Handle events on queue
                        while (SDL.SDL_PollEvent(out e) != 0)
                        {
                            //User requests quit
                            if (e.type == SDL.SDL_EventType.SDL_QUIT)
                            {
                                quit = true;
                            }
                            //Handle key press
                            else if (e.type == SDL.SDL_EventType.SDL_KEYDOWN)
                            {
                                switch (e.key.keysym.sym)
                                {
                                //Play high sound effect
                                case SDL.SDL_Keycode.SDLK_1:
                                    SDL_mixer.Mix_PlayChannel(-1, _High, 0);
                                    break;

                                //Play medium sound effect
                                case SDL.SDL_Keycode.SDLK_2:
                                    SDL_mixer.Mix_PlayChannel(-1, _Medium, 0);
                                    break;

                                //Play low sound effect
                                case SDL.SDL_Keycode.SDLK_3:
                                    SDL_mixer.Mix_PlayChannel(-1, _Low, 0);
                                    break;

                                //Play scratch sound effect
                                case SDL.SDL_Keycode.SDLK_4:
                                    SDL_mixer.Mix_PlayChannel(-1, _Scratch, 0);
                                    break;

                                case SDL.SDL_Keycode.SDLK_9:
                                    //If there is no music playing
                                    if (SDL_mixer.Mix_PlayingMusic() == 0)
                                    {
                                        //Play the music
                                        SDL_mixer.Mix_PlayMusic(_Music, -1);
                                    }
                                    //If music is being played
                                    else
                                    {
                                        //If the music is paused
                                        if (SDL_mixer.Mix_PausedMusic() == 1)
                                        {
                                            //Resume the music
                                            SDL_mixer.Mix_ResumeMusic();
                                        }
                                        //If the music is playing
                                        else
                                        {
                                            //Pause the music
                                            SDL_mixer.Mix_PauseMusic();
                                        }
                                    }
                                    break;

                                case SDL.SDL_Keycode.SDLK_0:
                                    //Stop the music
                                    SDL_mixer.Mix_HaltMusic();
                                    break;
                                }
                            }
                        }

                        //Clear screen
                        SDL.SDL_SetRenderDrawColor(Renderer, 0xFF, 0xFF, 0xFF, 0xFF);
                        SDL.SDL_RenderClear(Renderer);

                        //Render prompt
                        _PromptTexture.Render(0, 0);

                        //Update screen
                        SDL.SDL_RenderPresent(Renderer);
                    }
                }
            }


            //Free resources and close SDL
            Close();

            if (success == false)
            {
                Console.ReadLine();
            }

            return(0);
        }