event.c 493 B

12345678910111213141516171819202122232425262728293031
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <mpv/client.h>
  4. #include "event.h"
  5. #include "libmpv.h"
  6. void
  7. event_handler(void)
  8. {
  9. mpv_event *event = mpv_wait_event(ctx, 0.1);
  10. switch (event->event_id) {
  11. case MPV_EVENT_IDLE:
  12. fprintf(stderr, "event: %s\n", mpv_event_name(event->event_id));
  13. break;
  14. case MPV_EVENT_FILE_LOADED:
  15. libmpv_event_file_loaded();
  16. break;
  17. case MPV_EVENT_SHUTDOWN:
  18. mpv_terminate_destroy(ctx);
  19. exit(EXIT_SUCCESS);
  20. break;
  21. }
  22. fflush(stdout);
  23. return;
  24. }