diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 022830de5..1ca6a28dc 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -1325,9 +1325,16 @@ Song Playlist::current_item_metadata() const { } void Playlist::UpdateScrobblePoint() { - const int length = current_item_metadata().length_nanosec(); + const qint64 length = current_item_metadata().length_nanosec(); + + if (length == 0) { + scrobble_point_ = 240ll * kNsecPerSec; // 4 minutes + } else { + scrobble_point_ = qBound(31ll * kNsecPerSec, + length/2, + 240ll * kNsecPerSec); + } - scrobble_point_ = length == 0 ? 240 : qBound(31, length/2, 240); has_scrobbled_ = false; } diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 49f1dc9ee..ed6157560 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -182,7 +182,7 @@ class Playlist : public QAbstractListModel { void set_column_align_right(int column); // Scrobbling - int scrobble_point() const { return scrobble_point_; } + qint64 scrobble_point_nanosec() const { return scrobble_point_; } bool has_scrobbled() const { return has_scrobbled_; } void set_scrobbled(bool v) { has_scrobbled_ = v; } @@ -333,7 +333,7 @@ class Playlist : public QAbstractListModel { bool is_shuffled_; - int scrobble_point_; + qint64 scrobble_point_; bool has_scrobbled_; PlaylistSequence* playlist_sequence_; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 16b50b770..e4218d32c 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -973,6 +973,7 @@ void MainWindow::UpdateTrackPosition() { const int position = std::floor( float(player_->engine()->position_nanosec()) / kNsecPerSec + 0.5); const int length = item->Metadata().length_nanosec() / kNsecPerSec; + const int scrobble_point = playlists_->active()->scrobble_point_nanosec() / kNsecPerSec; if (length <= 0) { // Probably a stream that we don't know the length of @@ -982,9 +983,7 @@ void MainWindow::UpdateTrackPosition() { } // Time to scrobble? - - if (!playlists_->active()->has_scrobbled() && - position >= playlists_->active()->scrobble_point()) { + if (!playlists_->active()->has_scrobbled() && position >= scrobble_point) { #ifdef HAVE_LIBLASTFM radio_model_->RadioModel::Service()->Scrobble(); #endif