mplay

Controllable music player
git clone https://git.sinitax.com/sinitax/mplay
Log | Files | Refs | sfeed.txt

commit 5eb60cb925e4b3c477efd07016acb43510e7d6e9
parent 016d89d50b91a1865f04288b33c8f2d4779a5513
Author: Louis Burda <quent.burda@gmail.com>
Date:   Sat,  9 Mar 2024 22:10:05 +0100

Define status message format

Diffstat:
Mmplay.c | 2+-
Mmplay.h | 38++++++++++++++++++++++++++++++++++++--
2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/mplay.c b/mplay.c @@ -32,7 +32,7 @@ main(int argc, char **argv) struct dirent *ent; DIR *dir; - if (argc < 2) die("mplay [-f FMT] ... FILE[.FMT]"); + if (argc < 2) die("mplay [-d] [-f FMT] ... FILE[.FMT]"); path = strdup(getenv("PATH")); if (!path) die("PATH not set"); diff --git a/mplay.h b/mplay.h @@ -1,19 +1,41 @@ #pragma once +#include <stdarg.h> #include <stdio.h> +#define MPLAY_API_VERSION "0.0.1" + +#define MPLAY_FLAG_HEADLESS "-d" + +#define MPLAY_ACTION_STATUS_VERSION "version" #define MPLAY_ACTION_KEY_VERSION '?' + +#define MPLAY_ACTION_STATUS_STATUS "status" #define MPLAY_ACTION_KEY_STATUS 'S' + +#define MPLAY_ACTION_STATUS_VOL "vol" +#define MPLAY_ACTION_STATUS_VOL_UP "vol+" +#define MPLAY_ACTION_STATUS_VOL_DOWN "vol-" #define MPLAY_ACTION_KEY_VOL 'v' #define MPLAY_ACTION_KEY_VOL_UP '+' #define MPLAY_ACTION_KEY_VOL_DOWN '-' + +#define MPLAY_ACTION_STATUS_SEEK "seek" +#define MPLAY_ACTION_STATUS_SEEK_FWD "seek+" +#define MPLAY_ACTION_STATUS_SEEK_BWD "seek-" #define MPLAY_ACTION_KEY_SEEK 's' #define MPLAY_ACTION_KEY_SEEK_FWD '>' #define MPLAY_ACTION_KEY_SEEK_BWD '<' + +#define MPLAY_ACTION_STATUS_PLAYPAUSE "play" #define MPLAY_ACTION_KEY_PLAYPAUSE 'p' +#define MPLAY_STATUS_READY "ready" +#define MPLAY_STATUS_INPUT "input" +#define MPLAY_STATUS_EXIT "exit" + enum mplay_key { - MPLAY_KEY_INV, + MPLAY_KEY_INV = 256, MPLAY_KEY_EOF, MPLAY_KEY_UP, MPLAY_KEY_DOWN, @@ -77,7 +99,7 @@ mplay_getkey(void) } } -static int +static enum mplay_action mplay_action(int key) { switch (key) { @@ -108,3 +130,15 @@ mplay_action(int key) } } +static void +mplay_status(const char *cmd, const char *fmt, ...) +{ + va_list ap; + + if (!fmt) fmt = "ok"; + printf("mplay!:%s:", cmd); + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + va_end(ap); + fputc('\n', stdout); +}