From 1be863afdbe9017aa227234e8525b209fb818224 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Oct 2013 18:30:45 +0200 Subject: mplayer: fix some issues with playlist_prev command You couldn't jump to the first entry in the playlist, if that entry was marked as "too short". But this is usually fine, because it doesn't get into the way of the user. (This feature is meant to allow being able to jump backwards through the playlist even if a file immediately stops playback right after initialization, not to prevent playing these files at all.) Also, apply the skip logic when wrapping around the playlist when going backwards. This happens with --loop, because looping pretends the playlist is infinitely repeated forwards and backwards (as long as the playlist_prev/next commands are concerned). Also add some comments. --- mpvcore/mplayer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c index 7669a83851..b82e6a9e5d 100644 --- a/mpvcore/mplayer.c +++ b/mpvcore/mplayer.c @@ -4719,9 +4719,13 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction, bool force) { struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction); - if (direction < 0 && !force) { + if (next && direction < 0 && !force) { + // Don't jump to files that would immediately go to next file anyway while (next && next->playback_short) next = next->prev; + // Always allow jumping to first file + if (!next && mpctx->opts->loop_times < 0) + next = mpctx->playlist->first; } if (!next && mpctx->opts->loop_times >= 0) { if (direction > 0) { @@ -4735,8 +4739,12 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction, } } else { next = mpctx->playlist->last; + // Don't jump to files that would immediately go to next file anyway + while (next && next->playback_short) + next = next->prev; } if (!force && next && next->init_failed) { + // Don't endless loop if no file in playlist is playable bool all_failed = true; struct playlist_entry *cur; for (cur = mpctx->playlist->first; cur; cur = cur->next) { -- cgit v1.2.3