From 2273696850808ec6fa28f1a69427a0ebc931ff27 Mon Sep 17 00:00:00 2001 From: Stephane Bruckert Date: Wed, 12 Feb 2020 23:35:38 +0000 Subject: [PATCH] Add position_ms to start_playback --- CHANGELOG.md | 4 ++++ spotipy/client.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ebc6cc..d35f658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + + - Support `position_ms` optional parameter in `start_playback` + ## [2.8.0] - 2020-02-12 ### Added diff --git a/spotipy/client.py b/spotipy/client.py index ca7aeee..6c62c15 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -1170,7 +1170,7 @@ class Spotify(object): return self._put("me/player", payload=data) def start_playback( - self, device_id=None, context_uri=None, uris=None, offset=None + self, device_id=None, context_uri=None, uris=None, offset=None, position_ms=None ): """ Start or resume user's playback. @@ -1188,6 +1188,10 @@ class Spotify(object): - context_uri - spotify context uri to play - uris - spotify track uris - offset - offset into context by index or track + - position_ms - (optional) indicates from what position to start playback. + Must be a positive number. Passing in a position that is + greater than the length of the track will cause the player to + start playing the next song. """ if context_uri is not None and uris is not None: self._warn("specify either context uri or uris, not both") @@ -1202,6 +1206,8 @@ class Spotify(object): data["uris"] = uris if offset is not None: data["offset"] = offset + if position_ms is not None: + data["position_ms"] = position_ms return self._put( self._append_device_id("me/player/play", device_id), payload=data )