playlist: restart playing in deleteFromPlaylist()
When a song is deleted, start playing the next song immediately, within deleteFromPlaylist(). This allows us to remove the ugly playlist_noGoToNext flag, and the currentSongInPlaylist() function.
This commit is contained in:
parent
0d4319ed30
commit
9da7ae02f0
@ -70,7 +70,6 @@ static Playlist playlist;
|
|||||||
unsigned playlist_max_length;
|
unsigned playlist_max_length;
|
||||||
static int playlist_stopOnError;
|
static int playlist_stopOnError;
|
||||||
static unsigned playlist_errorCount;
|
static unsigned playlist_errorCount;
|
||||||
static int playlist_noGoToNext;
|
|
||||||
|
|
||||||
bool playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
|
bool playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
|
||||||
|
|
||||||
@ -594,12 +593,19 @@ enum playlist_result deleteFromPlaylist(unsigned song)
|
|||||||
/*if(playlist.current>=playlist.length) return playerStop(fd);
|
/*if(playlist.current>=playlist.length) return playerStop(fd);
|
||||||
else return playPlaylistOrderNumber(fd,playlist.current); */
|
else return playPlaylistOrderNumber(fd,playlist.current); */
|
||||||
playerWait();
|
playerWait();
|
||||||
playlist_noGoToNext = 1;
|
|
||||||
|
|
||||||
playlist.current = queue_next_order(&playlist.queue,
|
playlist.current = queue_next_order(&playlist.queue,
|
||||||
playlist.current);
|
playlist.current);
|
||||||
if (playlist.current == (int)songOrder)
|
if (playlist.current == (int)songOrder)
|
||||||
playlist.current = -1;
|
playlist.current = -1;
|
||||||
|
|
||||||
|
if (playlist.current >= 0)
|
||||||
|
/* play the song after the deleted one */
|
||||||
|
playPlaylistOrderNumber(playlist.current);
|
||||||
|
else
|
||||||
|
/* no songs left to play, stop playback
|
||||||
|
completely */
|
||||||
|
stopPlaylist();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!song_in_database(queue_get(&playlist.queue, song)))
|
if (!song_in_database(queue_get(&playlist.queue, song)))
|
||||||
@ -645,7 +651,6 @@ void stopPlaylist(void)
|
|||||||
playerWait();
|
playerWait();
|
||||||
playlist.queued = -1;
|
playlist.queued = -1;
|
||||||
playlist.playing = false;
|
playlist.playing = false;
|
||||||
playlist_noGoToNext = 0;
|
|
||||||
|
|
||||||
if (playlist.queue.random) {
|
if (playlist.queue.random) {
|
||||||
unsigned current_position =
|
unsigned current_position =
|
||||||
@ -664,7 +669,6 @@ static void playPlaylistOrderNumber(int orderNum)
|
|||||||
char *uri;
|
char *uri;
|
||||||
|
|
||||||
playlist.playing = true;
|
playlist.playing = true;
|
||||||
playlist_noGoToNext = 0;
|
|
||||||
playlist.queued = -1;
|
playlist.queued = -1;
|
||||||
|
|
||||||
song = queue_get_order(&playlist.queue, orderNum);
|
song = queue_get_order(&playlist.queue, orderNum);
|
||||||
@ -752,21 +756,6 @@ void syncPlayerAndPlaylist(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void currentSongInPlaylist(void)
|
|
||||||
{
|
|
||||||
if (!playlist.playing)
|
|
||||||
return;
|
|
||||||
|
|
||||||
playlist_stopOnError = 0;
|
|
||||||
|
|
||||||
syncPlaylistWithQueue();
|
|
||||||
|
|
||||||
if (playlist.current >= 0)
|
|
||||||
playPlaylistOrderNumber(playlist.current);
|
|
||||||
else
|
|
||||||
stopPlaylist();
|
|
||||||
}
|
|
||||||
|
|
||||||
void nextSongInPlaylist(void)
|
void nextSongInPlaylist(void)
|
||||||
{
|
{
|
||||||
int next_order;
|
int next_order;
|
||||||
@ -812,9 +801,7 @@ static void playPlaylistIfPlayerStopped(void)
|
|||||||
|| error == PLAYER_ERROR_SYSTEM
|
|| error == PLAYER_ERROR_SYSTEM
|
||||||
|| playlist_errorCount >= queue_length(&playlist.queue))) {
|
|| playlist_errorCount >= queue_length(&playlist.queue))) {
|
||||||
stopPlaylist();
|
stopPlaylist();
|
||||||
} else if (playlist_noGoToNext)
|
} else
|
||||||
currentSongInPlaylist();
|
|
||||||
else
|
|
||||||
nextSongInPlaylist();
|
nextSongInPlaylist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user