8 years, 4 months ago.

Stop playing the song

Great lib, thanks.

I play a song in a loop, and the loop stops when the user press the button. Then the song plays until the end is reached. Is there a way to stop the song immediately when the button is pressed?

bool play = 1;

void playMusic() { Music* pMusic = new Music(s); while (play) { pMusic->play(&buzzer); } delete(pMusic); }

void pressed() { play = 0; }

Question relating to:

A simple sound library for mbed. I use the Ring Tone Text Transfer Language (RTTTL) to play song with mbed. buzzer, music, RTTTL, sound
Be the first to answer this question.