1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 04:45:33 +00:00

command: make track properties cycle through no/auto if uninitialized

If playback has not been initialized yet (decoders not initialized
etc.), or if in idle mode, let the track properties cycle through "no"
and "auto". This should be slightly more helpful than making it simply
exit.

Depending on the stage of loading, more could be done. For example, if
youtube-dl loads additional subtitle files, it can happen that these get
added before the main file, and this could be cycled through to an
extent. This is probably too clever, and also sort of dangerous
(unintended interactions with messy in-loading state), so don't do it.
This commit is contained in:
wm4 2018-04-28 16:47:25 +02:00 committed by Jan Ekström
parent a208179ffe
commit 5731597342

View File

@ -2178,19 +2178,28 @@ static int property_switch_track(struct m_property *prop, int action, void *arg,
track->user_tid, lang);
}
} else {
*(char **) arg = talloc_strdup(NULL, "no");
const char *msg = "no";
if (!mpctx->playback_initialized &&
mpctx->opts->stream_id[order][type] == -1)
msg = "auto";
*(char **) arg = talloc_strdup(NULL, msg);
}
return M_PROPERTY_OK;
case M_PROPERTY_SWITCH: {
if (!mpctx->playback_initialized)
return M_PROPERTY_ERROR;
if (mpctx->playback_initialized) {
struct m_property_switch_arg *sarg = arg;
do {
track = track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track);
mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION);
} while (mpctx->current_track[order][type] != track);
print_track_list(mpctx, "Track switched:");
} else {
// Simply cycle between "no" and "auto". It's possible that this does
// not always do what the user means, but keep the complexity low.
mpctx->opts->stream_id[order][type] =
mpctx->opts->stream_id[order][type] == -1 ? -2 : -1;
}
return M_PROPERTY_OK;
}
case M_PROPERTY_SET: