mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 00:42:57 +00:00
command: add command to show playlist on OSD
This commit is contained in:
parent
314a07e787
commit
74817a77d4
@ -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,
|
||||
|
@ -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 } },
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user