SDL Mixer Pausing and Resume Music

Hello, I was wondering how would I pause the music and then resume it given user input? When I try to do it with pause the song, it jumps straight to return 0; (my breakpoint) and ignores the option to resume the music.

Here’s my code:
https://pastebin.com/aG0fwQJp

For posterity, here’s the pastebin’d code:


        Mix_PlayMusic(song, 1); //Play the song
        std::cin >> choice;
 
        if(Mix_PlayingMusic() == 1)
        {
            if (choice == "STOP")
            {
                Mix_PauseMusic();
                std::cin >> choice;
            }
        }
 
        else if (Mix_PausedMusic() == 1)
        {
            Mix_ResumeMusic();
        }
    Mix_FreeMusic(song);
    Mix_CloseAudio();
    Mix_Quit();
    SDL_Quit();
    return 0;

You’re definitely missing some code; this won’t compile as provided.

I notice you have an extra layer of indentation on the first 16 lines of the code, which looks like it used to be inside a loop of some sort? Seems like there should be some sort of while() loop around that, so that the program doesn’t just exit as soon as it takes a bit of input.


and here is a version with button and intersection testing.

-Cass