When stopping due to "Stop after this track", set the current song to the one after, so when the user presses Play it plays the next song instead of the last one again.

This commit is contained in:
David Sansome 2011-09-27 23:31:15 +01:00
parent 4c819b1cb9
commit 53e175e503
3 changed files with 22 additions and 7 deletions

View File

@ -129,11 +129,8 @@ void Player::Next() {
}
void Player::NextInternal(Engine::TrackChangeFlags change) {
if (playlists_->active()->stop_after_current()) {
playlists_->active()->StopAfter(-1);
Stop();
if (HandleStopAfter())
return;
}
if (playlists_->active()->current_item()) {
const QUrl url = playlists_->active()->current_item()->Url();
@ -164,12 +161,26 @@ void Player::NextItem(Engine::TrackChangeFlags change) {
PlayAt(i, change, false);
}
void Player::TrackEnded() {
bool Player::HandleStopAfter() {
if (playlists_->active()->stop_after_current()) {
playlists_->active()->StopAfter(-1);
// Find what the next track would've been, and mark that one as current
// so it plays next time the user presses Play.
const int next_row = playlists_->active()->next_row();
if (next_row != -1) {
playlists_->active()->set_current_row(next_row);
}
Stop();
return;
return true;
}
return false;
}
void Player::TrackEnded() {
if (HandleStopAfter())
return;
if (current_item_ && current_item_->IsLocalLibraryItem() &&
current_item_->Metadata().id() != -1 &&

View File

@ -163,6 +163,10 @@ public slots:
void UrlHandlerDestroyed(QObject* object);
void HandleLoadResult(const UrlHandler::LoadResult& result);
private:
// Returns true if we were supposed to stop after this track.
bool HandleStopAfter();
private:
PlaylistManagerInterface* playlists_;
LastFMService* lastfm_;

View File

@ -53,8 +53,8 @@
#include <QtConcurrentRun>
#include <QtDebug>
#include <boost/bind.hpp>
#include <algorithm>
#include <boost/bind.hpp>
using smart_playlists::Generator;
using smart_playlists::GeneratorInserter;