Skip to content

Commit

Permalink
playlist: let playlist-next go to first item if player is idle
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dudemanguy committed Jun 18, 2024
1 parent 4f3b5fc commit aa0a98e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,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;
}
Expand Down
1 change: 1 addition & 0 deletions common/playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct playlist {
struct playlist_entry *current;
bool current_was_replaced;
bool playlist_completed;
bool playlist_started;

uint64_t id_alloc;
};
Expand Down
1 change: 1 addition & 0 deletions player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,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);
Expand Down

0 comments on commit aa0a98e

Please sign in to comment.