diff --git a/src/core/player.cpp b/src/core/player.cpp index ec5038c3b..f601cdcfd 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -436,13 +436,9 @@ void Player::SeekTo(int seconds) { qBound(0ll, qint64(seconds) * kNsecPerSec, length_nanosec); engine_->Seek(nanosec); - // If we seek the track we don't want to submit it to last.fm - qLog(Info) << "Track seeked to" << nanosec << "ns - not scrobbling"; - if (app_->playlist_manager()->active()->get_lastfm_status() == - Playlist::LastFM_New) { - app_->playlist_manager()->active()->set_lastfm_status( - Playlist::LastFM_Seeked); - } + // If we seek the track we need to move the scrobble point + qLog(Info) << "Track seeked to" << nanosec << "ns - updating srobble point"; + app_->playlist_manager()->active()->UpdateScrobblePoint(nanosec); emit Seeked(nanosec / 1000); } diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 0fbd5e5e0..23542e4a8 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -1705,14 +1705,25 @@ Song Playlist::current_item_metadata() const { return current_item()->Metadata(); } -void Playlist::UpdateScrobblePoint() { +void Playlist::UpdateScrobblePoint(qint64 seek_point) { const qint64 length = current_item_metadata().length_nanosec(); - if (length == 0) { - scrobble_point_ = 240ll * kNsecPerSec; // 4 minutes + if (seek_point == 0) { + if (length == 0) { + scrobble_point_ = 240ll * kNsecPerSec; // 4 minutes + } else { + scrobble_point_ = + qBound(31ll * kNsecPerSec, length / 2, 240ll * kNsecPerSec); + } } else { - scrobble_point_ = - qBound(31ll * kNsecPerSec, length / 2, 240ll * kNsecPerSec); + if (length == 0) { + // current time + 4 minutes + scrobble_point_ = seek_point + (240ll * kNsecPerSec); + } else { + scrobble_point_ = + qBound(seek_point + (31ll * kNsecPerSec), seek_point + (length / 2), + seek_point + (240ll * kNsecPerSec)); + } } set_lastfm_status(LastFM_New); diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index a3a80cbb7..cafa9454f 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -227,6 +227,7 @@ class Playlist : public QAbstractListModel { } void set_lastfm_status(LastFMStatus status) { lastfm_status_ = status; } void set_have_incremented_playcount() { have_incremented_playcount_ = true; } + void UpdateScrobblePoint(qint64 seek_point = 0); // Changing the playlist void InsertItems(const PlaylistItemList& items, int pos = -1, @@ -351,7 +352,6 @@ signals: private: void SetCurrentIsPaused(bool paused); - void UpdateScrobblePoint(); int NextVirtualIndex(int i, bool ignore_repeat_track) const; int PreviousVirtualIndex(int i, bool ignore_repeat_track) const; bool FilterContainsVirtualIndex(int i) const;