mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 03:45:56 +01:00
When loading songs aync, always load the first song of our list, as it may be played immediately once added to the playlist
Fixes issue 2598
This commit is contained in:
parent
3b50ed8953
commit
7f89e8832e
@ -315,22 +315,27 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename, bool block,
|
||||
|
||||
void SongLoader::EffectiveSongsLoad() {
|
||||
for (int i = 0; i < songs_.size(); i++) {
|
||||
Song& song = songs_[i];
|
||||
EffectiveSongLoad(&songs_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (song.filetype() != Song::Type_Unknown) {
|
||||
// Maybe we loaded the metadata already, for example from a cuesheet.
|
||||
continue;
|
||||
}
|
||||
void SongLoader::EffectiveSongLoad(Song* song) {
|
||||
if (!song)
|
||||
return;
|
||||
|
||||
// First, try to get the song from the library
|
||||
Song library_song = library_->GetSongByUrl(song.url());
|
||||
if (library_song.is_valid()) {
|
||||
song = library_song;
|
||||
} else {
|
||||
// it's a normal media file
|
||||
QString filename = song.url().toLocalFile();
|
||||
TagReaderClient::Instance()->ReadFileBlocking(filename, &song);
|
||||
}
|
||||
if (song->filetype() != Song::Type_Unknown) {
|
||||
// Maybe we loaded the metadata already, for example from a cuesheet.
|
||||
return;
|
||||
}
|
||||
|
||||
// First, try to get the song from the library
|
||||
Song library_song = library_->GetSongByUrl(song->url());
|
||||
if (library_song.is_valid()) {
|
||||
*song = library_song;
|
||||
} else {
|
||||
// it's a normal media file
|
||||
QString filename = song->url().toLocalFile();
|
||||
TagReaderClient::Instance()->ReadFileBlocking(filename, song);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,6 +377,13 @@ void SongLoader::LoadLocalDirectory(const QString& filename) {
|
||||
}
|
||||
|
||||
qStableSort(songs_.begin(), songs_.end(), CompareSongs);
|
||||
|
||||
// Load the first song: all songs will be loaded async, but we want the first
|
||||
// one in our list to be fully loaded, so if the user has the "Start playing
|
||||
// when adding to playlist" preference behaviour set, it can enjoy the first
|
||||
// song being played (seek it, have moodbar, etc.)
|
||||
if (!songs_.isEmpty())
|
||||
EffectiveSongLoad(&(*songs_.begin()));
|
||||
}
|
||||
|
||||
void SongLoader::AddAsRawStream() {
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
// playlist and replace the partially-loaded items by the new ones, fully
|
||||
// loaded.
|
||||
void EffectiveSongsLoad();
|
||||
void EffectiveSongLoad(Song* song);
|
||||
Result LoadAudioCD();
|
||||
|
||||
signals:
|
||||
|
Loading…
Reference in New Issue
Block a user