Fix resuming playback position on startup

This commit is contained in:
Thor Merlin Lervik 2019-12-14 17:05:08 +01:00
parent 672b90659b
commit 715da8909f
2 changed files with 14 additions and 1 deletions

View File

@ -1342,7 +1342,19 @@ void MainWindow::ResumePlayback() {
app_->player()->Play();
app_->player()->SeekTo(saved_playback_position_);
connect(track_position_timer_, SIGNAL(timeout()),
SLOT(ResumePlaybackPosition()));
}
void MainWindow::ResumePlaybackPosition() {
// We must wait until the song has a length because
// seeking a song without length does not work
if (app_->player()->engine()->length_nanosec() > 0) {
disconnect(track_position_timer_, SIGNAL(timeout()), this,
SLOT(ResumePlaybackPosition()));
app_->player()->SeekTo(saved_playback_position_);
}
}
void MainWindow::PlayIndex(const QModelIndex& index) {

View File

@ -271,6 +271,7 @@ signals:
void SavePlaybackStatus(QSettings* settings);
void LoadPlaybackStatus();
void ResumePlayback();
void ResumePlaybackPosition();
void AddSongInfoGenerator(smart_playlists::GeneratorPtr gen);