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.
This commit is contained in:
wm4 2013-10-05 18:30:45 +02:00
parent c3ea08a2d7
commit 1be863afdb
1 changed files with 9 additions and 1 deletions

View File

@ -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) {