diff options
-rw-r--r-- | cplugins/README.md | 13 | ||||
-rw-r--r-- | cplugins/simple/simple.c | 23 |
2 files changed, 36 insertions, 0 deletions
diff --git a/cplugins/README.md b/cplugins/README.md new file mode 100644 index 0000000..06223e0 --- /dev/null +++ b/cplugins/README.md @@ -0,0 +1,13 @@ +# C plugin examples + +Documentation is here: https://mpv.io/manual/master/#c-plugins + +Other than this, the normal libmpv documentation applies. +Very primitive terminal-only example. Shows some most basic API usage. + +## List of Examples + +### simple + +Very primitive example showing basic API usage. + diff --git a/cplugins/simple/simple.c b/cplugins/simple/simple.c new file mode 100644 index 0000000..c8c6de8 --- /dev/null +++ b/cplugins/simple/simple.c @@ -0,0 +1,23 @@ +// Build with: gcc -o simple.so simple.c `pkg-config --cflags mpv` -shared -fPIC +// Warning: do not link against libmpv.so! Read: +// https://mpv.io/manual/master/#linkage-to-libmpv +// The pkg-config call is for adding the proper client.h include path. + +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> + +#include <mpv/client.h> + +int mpv_open_cplugin(mpv_handle *handle) +{ + printf("Hello world from C plugin '%s'!\n", mpv_client_name(handle)); + while (1) { + mpv_event *event = mpv_wait_event(handle, -1); + printf("Got event: %d\n", event->event_id); + if (event->event_id == MPV_EVENT_SHUTDOWN) + break; + } + return 0; +} + |