From 74817a77d45c96d4107b1946d0f918a893c58cac Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 6 Feb 2013 21:38:53 +0100 Subject: command: add command to show playlist on OSD --- core/command.c | 20 ++++++++++++++++++++ core/input/input.c | 1 + core/input/input.h | 1 + 3 files changed, 22 insertions(+) (limited to 'core') diff --git a/core/command.c b/core/command.c index 8331278148..4f304ded99 100644 --- a/core/command.c +++ b/core/command.c @@ -1739,6 +1739,23 @@ static void show_tracks_on_osd(MPContext *mpctx) talloc_free(res); } +static void show_playlist_on_osd(MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + char *res = NULL; + + for (struct playlist_entry *e = mpctx->playlist->first; e; e = e->next) { + if (mpctx->playlist->current == e) { + res = talloc_asprintf_append(res, "> %s <\n", e->filename); + } else { + res = talloc_asprintf_append(res, "%s\n", e->filename); + } + } + + set_osd_msg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration, "%s", res); + talloc_free(res); +} + void run_command(MPContext *mpctx, mp_cmd_t *cmd) { struct MPOpts *opts = &mpctx->opts; @@ -2308,6 +2325,9 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) case MP_CMD_SHOW_TRACKS: show_tracks_on_osd(mpctx); break; + case MP_CMD_SHOW_PLAYLIST: + show_playlist_on_osd(mpctx); + break; default: mp_msg(MSGT_CPLAYER, MSGL_V, diff --git a/core/input/input.c b/core/input/input.c index 06966ce25c..a03acd8e76 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -198,6 +198,7 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_SHOW_CHAPTERS, "show_chapters", }, { MP_CMD_SHOW_TRACKS, "show_tracks", }, + { MP_CMD_SHOW_PLAYLIST, "show_playlist", }, { MP_CMD_VO_CMDLINE, "vo_cmdline", { ARG_STRING } }, diff --git a/core/input/input.h b/core/input/input.h index b86f51a1e7..86726719b1 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -79,6 +79,7 @@ enum mp_command_type { MP_CMD_SHOW_CHAPTERS, MP_CMD_SHOW_TRACKS, + MP_CMD_SHOW_PLAYLIST, /// Video output commands MP_CMD_VO_CMDLINE, -- cgit v1.2.3