mirror of https://github.com/mpv-player/mpv
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:
parent
c3ea08a2d7
commit
1be863afdb
|
@ -4719,9 +4719,13 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
|
||||||
bool force)
|
bool force)
|
||||||
{
|
{
|
||||||
struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
|
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)
|
while (next && next->playback_short)
|
||||||
next = next->prev;
|
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 (!next && mpctx->opts->loop_times >= 0) {
|
||||||
if (direction > 0) {
|
if (direction > 0) {
|
||||||
|
@ -4735,8 +4739,12 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next = mpctx->playlist->last;
|
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) {
|
if (!force && next && next->init_failed) {
|
||||||
|
// Don't endless loop if no file in playlist is playable
|
||||||
bool all_failed = true;
|
bool all_failed = true;
|
||||||
struct playlist_entry *cur;
|
struct playlist_entry *cur;
|
||||||
for (cur = mpctx->playlist->first; cur; cur = cur->next) {
|
for (cur = mpctx->playlist->first; cur; cur = cur->next) {
|
||||||
|
|
Loading…
Reference in New Issue