diff --git a/src/core/audio/CrossfadeTransport.cpp b/src/core/audio/CrossfadeTransport.cpp index cf3f55c16..e55a47075 100644 --- a/src/core/audio/CrossfadeTransport.cpp +++ b/src/core/audio/CrossfadeTransport.cpp @@ -180,10 +180,6 @@ void CrossfadeTransport::SetPosition(double seconds) { } } - if (this->state == PlaybackPaused) { - SetPlaybackState(PlaybackPlaying); - } - if (this->active.player) { this->TimeChanged(seconds); } diff --git a/src/core/audio/GaplessTransport.cpp b/src/core/audio/GaplessTransport.cpp index 0d4597a7e..8ba1413c0 100644 --- a/src/core/audio/GaplessTransport.cpp +++ b/src/core/audio/GaplessTransport.cpp @@ -244,10 +244,6 @@ void GaplessTransport::SetPosition(double seconds) { } } - if (this->state == PlaybackPaused) { - SetPlaybackState(PlaybackPlaying); - } - if (this->activePlayer) { this->TimeChanged(seconds); } diff --git a/src/core/audio/PlaybackService.cpp b/src/core/audio/PlaybackService.cpp index d7e450a3a..adc59adee 100755 --- a/src/core/audio/PlaybackService.cpp +++ b/src/core/audio/PlaybackService.cpp @@ -691,8 +691,11 @@ void PlaybackService::Play(size_t index) { this->PlayAt(index, ITransport::StartMode::Immediate); } -void PlaybackService::Prepare(size_t index) { +void PlaybackService::Prepare(size_t index, double position) { this->PlayAt(index, ITransport::StartMode::Wait); + if (position > 0.0) { + this->transport.SetPosition(position); + } } size_t PlaybackService::GetIndex() { diff --git a/src/core/audio/PlaybackService.h b/src/core/audio/PlaybackService.h index 71f8c5874..73d920bd0 100755 --- a/src/core/audio/PlaybackService.h +++ b/src/core/audio/PlaybackService.h @@ -115,7 +115,7 @@ namespace musik { namespace core { namespace audio { concrete data types with known optimizations */ musik::core::audio::ITransport& GetTransport() { return this->transport; } void Play(const musik::core::TrackList& tracks, size_t index); - void Prepare(size_t index); + void Prepare(size_t index, double position = 0.0f); void CopyTo(musik::core::TrackList& target); void CopyFrom(const musik::core::TrackList& source); musik::core::TrackPtr GetTrackAtIndex(size_t index); diff --git a/src/musikcube/app/layout/NowPlayingLayout.cpp b/src/musikcube/app/layout/NowPlayingLayout.cpp index d937fea3b..c65fb8a08 100755 --- a/src/musikcube/app/layout/NowPlayingLayout.cpp +++ b/src/musikcube/app/layout/NowPlayingLayout.cpp @@ -98,7 +98,8 @@ void NowPlayingLayout::LoadLastSession() { int index = this->prefs->GetInt(keys::LastPlayQueueIndex, -1); if (index >= 0) { - this->playback.Prepare(index); + double time = this->prefs->GetDouble(keys::LastPlayQueueTime, 0.0f); + this->playback.Prepare(index, time); } } @@ -106,9 +107,11 @@ void NowPlayingLayout::SaveSession() { if (this->prefs->GetBool(keys::SaveSessionOnExit, false)) { if (playback.GetPlaybackState() != sdk::PlaybackStopped) { this->prefs->SetInt(keys::LastPlayQueueIndex, (int) playback.GetIndex()); + this->prefs->SetDouble(keys::LastPlayQueueTime, playback.GetPosition()); } else { this->prefs->SetInt(keys::LastPlayQueueIndex, -1); + this->prefs->SetDouble(keys::LastPlayQueueTime, 0.0f); } auto query = std::shared_ptr( diff --git a/src/musikcube/app/util/PreferenceKeys.cpp b/src/musikcube/app/util/PreferenceKeys.cpp index d6848b1d4..d34a98468 100644 --- a/src/musikcube/app/util/PreferenceKeys.cpp +++ b/src/musikcube/app/util/PreferenceKeys.cpp @@ -53,6 +53,7 @@ namespace musik { namespace cube { namespace prefs { const std::string keys::LastCategoryFilter = "LastCategoryFilter"; const std::string keys::LastTrackFilter = "LastTrackFilter"; const std::string keys::LastPlayQueueIndex = "LastPlayQueueIndex"; + const std::string keys::LastPlayQueueTime = "LastPlayQueueTime"; } } } diff --git a/src/musikcube/app/util/PreferenceKeys.h b/src/musikcube/app/util/PreferenceKeys.h index 2a8573cb1..d9438b47b 100644 --- a/src/musikcube/app/util/PreferenceKeys.h +++ b/src/musikcube/app/util/PreferenceKeys.h @@ -55,6 +55,7 @@ namespace musik { namespace cube { namespace prefs { extern const std::string LastCategoryFilter; extern const std::string LastTrackFilter; extern const std::string LastPlayQueueIndex; + extern const std::string LastPlayQueueTime; }