How to pause and resume song using Mbed code

#include "mbed.h"

InterruptIn button(BUTTON1);

volatile bool pressed = false;

void  buttonPress()
{
    if(!pressed) pressed = true;
}

int main()
{
    button.fall(callback(&buttonPress));
    //  main thread
    while(1) 
    {
        if(pressed)
        {
            // do something magic here 
            

            // clean after job done for another intrrupt
            pressed = false;
        }
        // rest of loop
    }
}

But there are many variants how you can solve it and it depends on your requirements. Usually simple InterruptIn - API references and tutorials | Mbed OS 6 Documentation or with combination of

BR, Jan