player/command: add albumart argument to video-add

Enables marking of specific video sources as album art.

Co-authored-by: Jan Ekström <jeebjp@gmail.com>
This commit is contained in:
Tom Wilson 2021-02-26 11:05:24 +00:00 committed by Jan Ekström
parent eef281e89e
commit d7f6eba233
3 changed files with 13 additions and 4 deletions

View File

@ -34,6 +34,8 @@ Interface changes
which didn't take the menu bar and Dock into account. The new default which didn't take the menu bar and Dock into account. The new default
behaviour includes both. To revert to the old behavior set this to behaviour includes both. To revert to the old behavior set this to
`whole`. `whole`.
- add an additional optional `albumart` argument to the `video-add` command,
which tells mpv to load the given video as album art.
--- mpv 0.33.0 --- --- mpv 0.33.0 ---
- add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode - add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode
when the player enters fullscreen. when the player enters fullscreen.

View File

@ -801,8 +801,11 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_).
``audio-reload [<id>]`` ``audio-reload [<id>]``
Reload the given audio tracks. See ``sub-reload`` command. Reload the given audio tracks. See ``sub-reload`` command.
``video-add <url> [<flags> [<title> [<lang>]]]`` ``video-add <url> [<flags> [<title> [<lang> [<albumart>]]]]``
Load the given video file. See ``sub-add`` command. Load the given video file. See ``sub-add`` command for common options.
``albumart`` (``MPV_FORMAT_FLAG``)
If enabled, mpv will load the given video as album art.
``video-remove [<id>]`` ``video-remove [<id>]``
Remove the given video track. See ``sub-remove`` command. Remove the given video track. See ``sub-remove`` command.

View File

@ -5241,6 +5241,8 @@ static void cmd_track_add(void *p)
struct mp_cmd_ctx *cmd = p; struct mp_cmd_ctx *cmd = p;
struct MPContext *mpctx = cmd->mpctx; struct MPContext *mpctx = cmd->mpctx;
int type = *(int *)cmd->priv; int type = *(int *)cmd->priv;
bool is_albumart = type == STREAM_VIDEO &&
cmd->args[4].v.i;
if (mpctx->stop_play) { if (mpctx->stop_play) {
cmd->success = false; cmd->success = false;
@ -5260,7 +5262,7 @@ static void cmd_track_add(void *p)
} }
} }
int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type, int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type,
cmd->abort->cancel, false); cmd->abort->cancel, is_albumart);
if (first < 0) { if (first < 0) {
cmd->success = false; cmd->success = false;
return; return;
@ -5323,9 +5325,10 @@ static void cmd_track_reload(void *p)
if (t && t->is_external && t->external_filename) { if (t && t->is_external && t->external_filename) {
char *filename = talloc_strdup(NULL, t->external_filename); char *filename = talloc_strdup(NULL, t->external_filename);
bool is_albumart = t->attached_picture;
mp_remove_track(mpctx, t); mp_remove_track(mpctx, t);
nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel, nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel,
false); is_albumart);
talloc_free(filename); talloc_free(filename);
} }
@ -6072,6 +6075,7 @@ const struct mp_cmd_def mp_cmds[] = {
.flags = MP_CMD_OPT_ARG}, .flags = MP_CMD_OPT_ARG},
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG}, {"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG}, {"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
{"albumart", OPT_FLAG(v.i), .flags = MP_CMD_OPT_ARG},
}, },
.priv = &(const int){STREAM_VIDEO}, .priv = &(const int){STREAM_VIDEO},
.spawn_thread = true, .spawn_thread = true,