mirror of https://github.com/mpv-player/mpv
playlist: let playlist-next go to first item if player is idle
Similar to the previous commit but the other way around. If you start mpv as idle, load up a playlist without immediately hitting play and then try to go to the next item, nothing happens. Naturally, you would expect this to go to the first item. Fix this detecting if the playlist has not started yet, the direction, and going to the first item in the list.
This commit is contained in:
parent
0f76848e5f
commit
0db6abadd4
|
@ -116,6 +116,7 @@ void playlist_clear(struct playlist *pl)
|
|||
assert(!pl->current);
|
||||
pl->current_was_replaced = false;
|
||||
pl->playlist_completed = false;
|
||||
pl->playlist_started = false;
|
||||
}
|
||||
|
||||
void playlist_clear_except_current(struct playlist *pl)
|
||||
|
@ -125,6 +126,7 @@ void playlist_clear_except_current(struct playlist *pl)
|
|||
playlist_remove(pl, pl->entries[n]);
|
||||
}
|
||||
pl->playlist_completed = false;
|
||||
pl->playlist_started = false;
|
||||
}
|
||||
|
||||
// Moves the entry so that it takes "at"'s place (or move to end, if at==NULL).
|
||||
|
@ -209,6 +211,8 @@ struct playlist_entry *playlist_get_next(struct playlist *pl, int direction)
|
|||
assert(direction == -1 || direction == +1);
|
||||
if (!pl->current && pl->playlist_completed && direction < 0) {
|
||||
return playlist_entry_from_index(pl, pl->num_entries - 1);
|
||||
} else if (!pl->current && !pl->playlist_started && direction > 0) {
|
||||
return playlist_entry_from_index(pl, 0);
|
||||
} else if (!pl->current) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -339,6 +343,7 @@ int64_t playlist_transfer_entries_to(struct playlist *pl, int dst_index,
|
|||
source_pl->num_entries = 0;
|
||||
|
||||
pl->playlist_completed = source_pl->playlist_completed;
|
||||
pl->playlist_started = source_pl->playlist_started;
|
||||
|
||||
return first ? first->id : 0;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ struct playlist {
|
|||
struct playlist_entry *current;
|
||||
bool current_was_replaced;
|
||||
bool playlist_completed;
|
||||
bool playlist_started;
|
||||
|
||||
uint64_t id_alloc;
|
||||
};
|
||||
|
|
|
@ -1033,6 +1033,7 @@ void prepare_playlist(struct MPContext *mpctx, struct playlist *pl)
|
|||
|
||||
pl->current = NULL;
|
||||
pl->playlist_completed = false;
|
||||
pl->playlist_started = false;
|
||||
|
||||
if (opts->playlist_pos >= 0)
|
||||
pl->current = playlist_entry_from_index(pl, opts->playlist_pos);
|
||||
|
@ -1762,6 +1763,7 @@ static void play_current_file(struct MPContext *mpctx)
|
|||
mpctx->playback_initialized = true;
|
||||
mpctx->playing->playlist_prev_attempt = false;
|
||||
mpctx->playlist->playlist_completed = false;
|
||||
mpctx->playlist->playlist_started = true;
|
||||
mp_notify(mpctx, MPV_EVENT_FILE_LOADED, NULL);
|
||||
update_screensaver_state(mpctx);
|
||||
clear_playlist_paths(mpctx);
|
||||
|
|
Loading…
Reference in New Issue