From 8859ff1d3bf3f33443dd83064b0b771877b8f544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Thu, 15 Nov 2018 13:57:17 +0100 Subject: [PATCH] Don't stop audio right after play start The common play skill sends a stop message in the CPS_start(), if the play message is sent too close to the stop message it may be executed before the stop message causing playback to immediately stop. To circumvent this a 1 second stop ignore time is added. --- mycroft/audio/audioservice.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mycroft/audio/audioservice.py b/mycroft/audio/audioservice.py index 5241ad92d4..996c5319c6 100644 --- a/mycroft/audio/audioservice.py +++ b/mycroft/audio/audioservice.py @@ -143,6 +143,7 @@ class AudioService(object): self.default = None self.service = [] self.current = None + self.play_start_time = 0 self.volume_is_low = False self.pulse = None self.pulse_quiet = None @@ -249,15 +250,16 @@ class AudioService(object): Args: message: message bus message, not used but required """ - LOG.debug('stopping all playing services') - with self.service_lock: - if self.current: - name = self.current.name - if self.current.stop(): - self.bus.emit(Message("mycroft.stop.handled", - {"by": "audio:" + name})) + if time.monotonic() - self.play_start_time > 1: + LOG.debug('stopping all playing services') + with self.service_lock: + if self.current: + name = self.current.name + if self.current.stop(): + self.bus.emit(Message("mycroft.stop.handled", + {"by": "audio:" + name})) - self.current = None + self.current = None def _lower_volume(self, message=None): """ @@ -374,6 +376,7 @@ class AudioService(object): selected_service.add_list(tracks) selected_service.play(repeat) self.current = selected_service + self.play_start_time = time.monotonic() def _queue(self, message): if self.current: