Skip to content

Commit 5a5be75

Browse files
committed
Spotify: Provide required argument for /play request
1 parent 923df4b commit 5a5be75

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/query/spotify_source.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void spotify_source::load()
105105

106106
/* implementation further down */
107107
long execute_command(const char* auth_token, const char* url, std::string& response_header,
108-
QJsonDocument& response_json, const char* custom_request_type = nullptr);
108+
QJsonDocument& response_json, const char* custom_request_type = nullptr, const char* request_data = nullptr);
109109

110110
void extract_timeout(const std::string& header, uint64_t& timeout)
111111
{
@@ -301,7 +301,7 @@ bool spotify_source::execute_capability(capability c)
301301
case CAP_STOP_SONG:
302302
http_code = execute_command(qt_to_utf8(token), PLAYER_PAUSE_URL, header, response, "PUT");
303303
} else {
304-
http_code = execute_command(qt_to_utf8(token), PLAYER_PLAY_URL, header, response, "PUT");
304+
http_code = execute_command(qt_to_utf8(token), PLAYER_PLAY_URL, header, response, "PUT", "{\"position_ms\": 0}");
305305
}
306306
break;
307307
case CAP_PREV_SONG:
@@ -504,7 +504,7 @@ bool spotify_source::new_token(QString& log)
504504
/* Sends commands to spotify api via url */
505505

506506
long execute_command(const char* auth_token, const char* url, std::string& response_header,
507-
QJsonDocument& response_json, const char* custom_request_type)
507+
QJsonDocument& response_json, const char* custom_request_type, const char* request_data)
508508
{
509509
static int timeout_start = 0;
510510
static int timeout = 0;
@@ -538,7 +538,10 @@ long execute_command(const char* auth_token, const char* url, std::string& respo
538538

539539
if (custom_request_type != nullptr) {
540540
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_request_type);
541-
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{}");
541+
if (request_data)
542+
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request_data);
543+
else
544+
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{}");
542545
}
543546

544547
if (!response_header.empty())

0 commit comments

Comments
 (0)