mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Round out session resumption: remember and restore the play head.
This commit is contained in:
parent
8550e62b1d
commit
177cf1851e
@ -180,10 +180,6 @@ void CrossfadeTransport::SetPosition(double seconds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->state == PlaybackPaused) {
|
|
||||||
SetPlaybackState(PlaybackPlaying);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->active.player) {
|
if (this->active.player) {
|
||||||
this->TimeChanged(seconds);
|
this->TimeChanged(seconds);
|
||||||
}
|
}
|
||||||
|
@ -244,10 +244,6 @@ void GaplessTransport::SetPosition(double seconds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->state == PlaybackPaused) {
|
|
||||||
SetPlaybackState(PlaybackPlaying);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->activePlayer) {
|
if (this->activePlayer) {
|
||||||
this->TimeChanged(seconds);
|
this->TimeChanged(seconds);
|
||||||
}
|
}
|
||||||
|
@ -691,8 +691,11 @@ void PlaybackService::Play(size_t index) {
|
|||||||
this->PlayAt(index, ITransport::StartMode::Immediate);
|
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);
|
this->PlayAt(index, ITransport::StartMode::Wait);
|
||||||
|
if (position > 0.0) {
|
||||||
|
this->transport.SetPosition(position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PlaybackService::GetIndex() {
|
size_t PlaybackService::GetIndex() {
|
||||||
|
@ -115,7 +115,7 @@ namespace musik { namespace core { namespace audio {
|
|||||||
concrete data types with known optimizations */
|
concrete data types with known optimizations */
|
||||||
musik::core::audio::ITransport& GetTransport() { return this->transport; }
|
musik::core::audio::ITransport& GetTransport() { return this->transport; }
|
||||||
void Play(const musik::core::TrackList& tracks, size_t index);
|
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 CopyTo(musik::core::TrackList& target);
|
||||||
void CopyFrom(const musik::core::TrackList& source);
|
void CopyFrom(const musik::core::TrackList& source);
|
||||||
musik::core::TrackPtr GetTrackAtIndex(size_t index);
|
musik::core::TrackPtr GetTrackAtIndex(size_t index);
|
||||||
|
@ -98,7 +98,8 @@ void NowPlayingLayout::LoadLastSession() {
|
|||||||
|
|
||||||
int index = this->prefs->GetInt(keys::LastPlayQueueIndex, -1);
|
int index = this->prefs->GetInt(keys::LastPlayQueueIndex, -1);
|
||||||
if (index >= 0) {
|
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 (this->prefs->GetBool(keys::SaveSessionOnExit, false)) {
|
||||||
if (playback.GetPlaybackState() != sdk::PlaybackStopped) {
|
if (playback.GetPlaybackState() != sdk::PlaybackStopped) {
|
||||||
this->prefs->SetInt(keys::LastPlayQueueIndex, (int) playback.GetIndex());
|
this->prefs->SetInt(keys::LastPlayQueueIndex, (int) playback.GetIndex());
|
||||||
|
this->prefs->SetDouble(keys::LastPlayQueueTime, playback.GetPosition());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->prefs->SetInt(keys::LastPlayQueueIndex, -1);
|
this->prefs->SetInt(keys::LastPlayQueueIndex, -1);
|
||||||
|
this->prefs->SetDouble(keys::LastPlayQueueTime, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto query = std::shared_ptr<PersistedPlayQueueQuery>(
|
auto query = std::shared_ptr<PersistedPlayQueueQuery>(
|
||||||
|
@ -53,6 +53,7 @@ namespace musik { namespace cube { namespace prefs {
|
|||||||
const std::string keys::LastCategoryFilter = "LastCategoryFilter";
|
const std::string keys::LastCategoryFilter = "LastCategoryFilter";
|
||||||
const std::string keys::LastTrackFilter = "LastTrackFilter";
|
const std::string keys::LastTrackFilter = "LastTrackFilter";
|
||||||
const std::string keys::LastPlayQueueIndex = "LastPlayQueueIndex";
|
const std::string keys::LastPlayQueueIndex = "LastPlayQueueIndex";
|
||||||
|
const std::string keys::LastPlayQueueTime = "LastPlayQueueTime";
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ namespace musik { namespace cube { namespace prefs {
|
|||||||
extern const std::string LastCategoryFilter;
|
extern const std::string LastCategoryFilter;
|
||||||
extern const std::string LastTrackFilter;
|
extern const std::string LastTrackFilter;
|
||||||
extern const std::string LastPlayQueueIndex;
|
extern const std::string LastPlayQueueIndex;
|
||||||
|
extern const std::string LastPlayQueueTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user