@@ -105,7 +105,7 @@ void spotify_source::load()
105105
106106/* implementation further down */
107107long 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
110110void 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
506506long 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