Skip to content
Snippets Groups Projects
Commit 7effe35e authored by Robert Goldmann's avatar Robert Goldmann
Browse files

SpotifyRecorder: make sure no track is playing when starting to record next track

parent 44571bdb
Branches
Tags
No related merge requests found
......@@ -109,6 +109,8 @@ class SpotifyRecorder:
LOGGER.info(
f'>>> Recording track {index + 1}/{len(tracks)}: #{indexInPlaylist} "{track["track"]["name"]}"...')
try:
self.__stop_playback_if_playing(deviceId)
filePath = self.__determine_file_path(indexInPlaylist + 1, track)
recorder = SpotifyAudioRecorder(self._audioDeviceName, filePath)
with recorder.record():
......@@ -194,6 +196,10 @@ class SpotifyRecorder:
def __play_track(self, deviceId: str, trackUri: str) -> None:
self._spotify.start_playback(device_id=deviceId, uris=[trackUri])
def __stop_playback_if_playing(self, deviceId: str) -> None:
if self._spotify.current_playback()['is_playing']:
self._spotify.pause_playback(device_id=deviceId)
def __wait_for_track_playing(self, expectedTrackId: str) -> float:
LOGGER.debug(f'\t\tWait for track to start playing...')
startTime = time.time()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment