Skip to content

Commit

Permalink
examples/audiolite_mp3player: Add way to stop during playing
Browse files Browse the repository at this point in the history
Add a way to stop the application when the music is not finished.
  • Loading branch information
SPRESENSE committed Nov 5, 2024
1 parent e680292 commit 77bcf90
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/audiolite_mp3player/audiolite_mp3player_main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#include <nuttx/config.h>
#include <stdio.h>
#include <poll.h>
#include <fcntl.h>

#include <audiolite/audiolite.h>

Expand Down Expand Up @@ -81,6 +83,7 @@ int main(int argc, FAR char *argv[])
int ret;
my_mp3listener lsn;
int volume = 1000;
struct pollfd pfd;

/* Argument check */

Expand Down Expand Up @@ -191,7 +194,17 @@ int main(int argc, FAR char *argv[])

while (lsn.playing)
{
usleep(10 * 1000);
pfd.fd = fileno(stdin);
pfd.events = POLLIN;

poll(&pfd, 1, 10 /* ms */);
if (pfd.revents & POLLIN)
{
if (getchar() == 'q')
{
break;
}
}
}

/* Stop playing */
Expand Down

0 comments on commit 77bcf90

Please sign in to comment.