From c008ab6141bc679a6d0101e86faad91a26a300ca Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 25 Apr 2020 15:57:02 +0200 Subject: [PATCH] Fix resume playback on startup for CUE --- src/core/mainwindow.cpp | 11 ++++++++++- src/core/mainwindow.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index ea6b8c970..0c55bad1d 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -1234,8 +1234,9 @@ void MainWindow::ResumePlayback() { if (playback_state == Engine::Paused) { NewClosure(app_->player(), SIGNAL(Playing()), app_->player(), SLOT(PlayPause())); } + // Seek after we got song length. + NewClosure(track_position_timer_, SIGNAL(timeout()), this, SLOT(ResumePlaybackSeek(int)), playback_position); app_->player()->Play(); - app_->player()->SeekTo(playback_position); } // Reset saved playback status so we don't resume again from the same position. @@ -1247,6 +1248,14 @@ void MainWindow::ResumePlayback() { } +void MainWindow::ResumePlaybackSeek(const int playback_position) { + + if (app_->player()->engine()->length_nanosec() > 0) { + app_->player()->SeekTo(playback_position); + } + +} + void MainWindow::PlayIndex(const QModelIndex &index) { if (!index.isValid()) return; diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index d44a23a64..4adfe8ca1 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -236,6 +236,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { void SavePlaybackStatus(); void LoadPlaybackStatus(); void ResumePlayback(); + void ResumePlaybackSeek(const int playback_position); void Raise();