1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-30 11:42:04 +00:00

command: try selecting the next track if track switching fails

This affects the "cycle" command. If we switched to the next track, and
it failed to initialize, we just deselected everything.

Change it so that if initialization fails early (typically decoder
selection), we try to continue with the track after that. (Even if
nothing can be selected, the loop will terminate when trying to select
nothing.

Fixes #3446.
This commit is contained in:
wm4 2016-09-03 16:39:59 +02:00
parent 0c2c059826
commit 590caeb2bd

View File

@ -1961,9 +1961,10 @@ static int property_switch_track(struct m_property *prop, int action, void *arg,
if (!mpctx->playback_initialized)
return M_PROPERTY_ERROR;
struct m_property_switch_arg *sarg = arg;
mp_switch_track_n(mpctx, order, type,
track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track),
FLAG_MARK_SELECTION);
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:");
return M_PROPERTY_OK;
}