Fix resume playback on startup
This commit is contained in:
@@ -68,7 +68,8 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent)
|
||||
parser_(nullptr),
|
||||
playlist_container_(nullptr),
|
||||
current_(-1),
|
||||
active_(-1)
|
||||
active_(-1),
|
||||
playlists_loading_(0)
|
||||
{
|
||||
connect(app_->player(), SIGNAL(Paused()), SLOT(SetActivePaused()));
|
||||
connect(app_->player(), SIGNAL(Playing()), SLOT(SetActivePlaying()));
|
||||
@@ -93,7 +94,9 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken
|
||||
connect(collection_backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsDiscovered(SongList)));
|
||||
|
||||
for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) {
|
||||
AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);
|
||||
playlists_loading_++;
|
||||
Playlist *ret = AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);
|
||||
connect(ret, SIGNAL(PlaylistLoaded()), SLOT(PlaylistLoaded()));
|
||||
}
|
||||
|
||||
// If no playlist exists then make a new one
|
||||
@@ -103,6 +106,16 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken
|
||||
|
||||
}
|
||||
|
||||
void PlaylistManager::PlaylistLoaded() {
|
||||
|
||||
Playlist *playlist = qobject_cast<Playlist*>(sender());
|
||||
if (!playlist) return;
|
||||
disconnect(playlist, SIGNAL(PlaylistLoaded()), this, SLOT(PlaylistLoaded()));
|
||||
playlists_loading_--;
|
||||
if (playlists_loading_ == 0) emit AllPlaylistsLoaded();
|
||||
|
||||
}
|
||||
|
||||
QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
|
||||
|
||||
QList<Playlist*> result;
|
||||
@@ -359,8 +372,7 @@ void PlaylistManager::SetActivePlaylist(int id) {
|
||||
|
||||
Q_ASSERT(playlists_.contains(id));
|
||||
|
||||
// Kinda a hack: unset the current item from the old active playlist before
|
||||
// setting the new one
|
||||
// Kinda a hack: unset the current item from the old active playlist before setting the new one
|
||||
if (active_ != -1 && active_ != id) active()->set_current_row(-1);
|
||||
|
||||
active_ = id;
|
||||
|
||||
Reference in New Issue
Block a user