| 1 |
|
| 2 |
|
| 3 |
#include <rplay.h> |
| 4 |
|
| 5 |
static void event_callback(int fd, int event, char *line); |
| 6 |
|
| 7 |
main(int argc, char **argv) |
| 8 |
{ |
| 9 |
char buf[RPTP_MAX_LINE]; |
| 10 |
int fd; |
| 11 |
|
| 12 |
fd = rptp_open(rplay_default_host(), RPTP_PORT, buf, sizeof(buf)); |
| 13 |
|
| 14 |
rptp_async_notify(fd, |
| 15 |
RPTP_EVENT_PLAY | RPTP_EVENT_PAUSE | RPTP_EVENT_DONE | RPTP_EVENT_CONTINUE, |
| 16 |
event_callback); |
| 17 |
|
| 18 |
rptp_main_loop(); |
| 19 |
|
| 20 |
exit(0); |
| 21 |
} |
| 22 |
|
| 23 |
static void |
| 24 |
event_callback(int fd, int event, char *line) |
| 25 |
{ |
| 26 |
switch (event) |
| 27 |
{ |
| 28 |
case RPTP_EVENT_PLAY: |
| 29 |
printf("%s is playing\n", rptp_parse(line, "sound")); |
| 30 |
break; |
| 31 |
|
| 32 |
case RPTP_EVENT_PAUSE: |
| 33 |
printf("%s is paused\n", rptp_parse(line, "sound")); |
| 34 |
break; |
| 35 |
|
| 36 |
case RPTP_EVENT_DONE: |
| 37 |
printf("%s is done\n", rptp_parse(line, "sound")); |
| 38 |
break; |
| 39 |
|
| 40 |
case RPTP_EVENT_CONTINUE: |
| 41 |
printf("%s continue\n", rptp_parse(line, "sound")); |
| 42 |
break; |
| 43 |
} |
| 44 |
} |