diff --git a/ext/clementine-spotifyblob/spotifyclient.cpp b/ext/clementine-spotifyblob/spotifyclient.cpp index 643180892..265a863b5 100644 --- a/ext/clementine-spotifyblob/spotifyclient.cpp +++ b/ext/clementine-spotifyblob/spotifyclient.cpp @@ -30,6 +30,7 @@ #include "core/arraysize.h" #include "core/logging.h" +#include "core/timeconstants.h" #include "mediapipeline.h" #include "spotifykey.h" #include "spotifymessages.pb.h" @@ -279,7 +280,7 @@ void SpotifyClient::MessageArrived(const pb::spotify::Message& message) { } else if (message.has_playback_request()) { StartPlayback(message.playback_request()); } else if (message.has_seek_request()) { - Seek(message.seek_request().offset_bytes()); + Seek(message.seek_request().offset_nsec()); } else if (message.has_search_request()) { Search(message.search_request()); } else if (message.has_image_request()) { @@ -844,8 +845,9 @@ void SpotifyClient::StartPlayback(const pb::spotify::PlaybackRequest& req) { TryPlaybackAgain(pending_playback); } -void SpotifyClient::Seek(qint64 offset_bytes) { - if (sp_session_player_seek(session_, offset_bytes) != SP_ERROR_OK) { +void SpotifyClient::Seek(qint64 offset_nsec) { + if (sp_session_player_seek(session_, offset_nsec / kNsecPerMsec) + != SP_ERROR_OK) { qLog(Error) << "Seek error"; return; } diff --git a/ext/clementine-spotifyblob/spotifyclient.h b/ext/clementine-spotifyblob/spotifyclient.h index 3651cbf4a..02d908cd6 100644 --- a/ext/clementine-spotifyblob/spotifyclient.h +++ b/ext/clementine-spotifyblob/spotifyclient.h @@ -124,7 +124,7 @@ class SpotifyClient : public AbstractMessageHandler { void LoadPlaylist(const pb::spotify::LoadPlaylistRequest& req); void SyncPlaylist(const pb::spotify::SyncPlaylistRequest& req); void StartPlayback(const pb::spotify::PlaybackRequest& req); - void Seek(qint64 offset_bytes); + void Seek(qint64 offset_nsec); void LoadImage(const QString& id_b64); void BrowseAlbum(const QString& uri); void BrowseToplist(const pb::spotify::BrowseToplistRequest& req); diff --git a/ext/libclementine-spotifyblob/spotifymessages.proto b/ext/libclementine-spotifyblob/spotifymessages.proto index 0f16ce85d..fdaac676f 100644 --- a/ext/libclementine-spotifyblob/spotifymessages.proto +++ b/ext/libclementine-spotifyblob/spotifymessages.proto @@ -170,7 +170,7 @@ message BrowseToplistResponse { } message SeekRequest { - optional int64 offset_bytes = 1; + optional int64 offset_nsec = 1; } message SeekCompleted { diff --git a/src/engines/gstenginepipeline.cpp b/src/engines/gstenginepipeline.cpp index 0c3487a11..275fd2715 100644 --- a/src/engines/gstenginepipeline.cpp +++ b/src/engines/gstenginepipeline.cpp @@ -947,11 +947,10 @@ bool GstEnginePipeline::Seek(qint64 nanosec) { SpotifyService* spotify = InternetModel::Service(); // Need to schedule this in the spotify service's thread QMetaObject::invokeMethod(spotify, "Seek", Qt::QueuedConnection, - Q_ARG(int, nanosec / kNsecPerMsec)); + Q_ARG(qint64, nanosec)); // Need to reset spotify_offset_ to get the real pipeline position, as it is // used in position() - spotify_offset_ = 0; - spotify_offset_ = nanosec - position() ; + spotify_offset_ = nanosec - position(); return true; } diff --git a/src/internet/spotifyserver.cpp b/src/internet/spotifyserver.cpp index 2db580ae5..dea7e72d6 100644 --- a/src/internet/spotifyserver.cpp +++ b/src/internet/spotifyserver.cpp @@ -224,11 +224,11 @@ void SpotifyServer::StartPlayback(const QString& uri, quint16 port) { SendOrQueueMessage(message); } -void SpotifyServer::Seek(qint64 offset_bytes) { +void SpotifyServer::Seek(qint64 offset_nsec) { pb::spotify::Message message; pb::spotify::SeekRequest* req = message.mutable_seek_request(); - req->set_offset_bytes(offset_bytes); + req->set_offset_nsec(offset_nsec); SendOrQueueMessage(message); } diff --git a/src/internet/spotifyserver.h b/src/internet/spotifyserver.h index 6a491a344..48f2d6773 100644 --- a/src/internet/spotifyserver.h +++ b/src/internet/spotifyserver.h @@ -56,7 +56,7 @@ class SpotifyServer : public AbstractMessageHandler { public slots: void StartPlayback(const QString& uri, quint16 port); - void Seek(qint64 offset_bytes); + void Seek(qint64 offset_nsec); signals: void LoginCompleted(bool success, const QString& error, diff --git a/src/internet/spotifyservice.cpp b/src/internet/spotifyservice.cpp index 838ab6d38..0ad02fef2 100644 --- a/src/internet/spotifyservice.cpp +++ b/src/internet/spotifyservice.cpp @@ -693,14 +693,14 @@ void SpotifyService::LoadImage(const QString& id) { server_->LoadImage(id); } -void SpotifyService::SetPaused(const bool paused) { +void SpotifyService::SetPaused(bool paused) { EnsureServerCreated(); server_->SetPaused(paused); } -void SpotifyService::Seek(const int offset /* in msec */) { +void SpotifyService::Seek(qint64 offset_nsec) { EnsureServerCreated(); - server_->Seek(offset); + server_->Seek(offset_nsec); } void SpotifyService::SyncPlaylistProgress( diff --git a/src/internet/spotifyservice.h b/src/internet/spotifyservice.h index 10efb2744..a52aa063b 100644 --- a/src/internet/spotifyservice.h +++ b/src/internet/spotifyservice.h @@ -58,8 +58,8 @@ class SpotifyService : public InternetService { void Logout(); void Login(const QString& username, const QString& password); Q_INVOKABLE void LoadImage(const QString& id); - Q_INVOKABLE void SetPaused(const bool paused); - Q_INVOKABLE void Seek(const int offset /* in msec */); + Q_INVOKABLE void SetPaused(bool paused); + Q_INVOKABLE void Seek(qint64 offset_nsec); SpotifyServer* server() const;