From d86ffe7d5482e322d24438532f1659df7e0588df Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 1 Oct 2010 23:31:41 +0200 Subject: [PATCH] Do not send {started,stopped}_playing events without track data (fixes GH-23) --- mopidy/backends/base/playback.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mopidy/backends/base/playback.py b/mopidy/backends/base/playback.py index 3c887120..00676f09 100644 --- a/mopidy/backends/base/playback.py +++ b/mopidy/backends/base/playback.py @@ -501,11 +501,12 @@ class BasePlaybackController(object): For internal use only. Should be called by the backend directly after a track has started playing. """ - self.backend.core_queue.put({ - 'to': 'frontend', - 'command': 'started_playing', - 'track': self.current_track, - }) + if self.current_track is not None: + self.backend.core_queue.put({ + 'to': 'frontend', + 'command': 'started_playing', + 'track': self.current_track, + }) def _trigger_stopped_playing_event(self): """ @@ -515,9 +516,10 @@ class BasePlaybackController(object): is stopped playing, e.g. at the next, previous, and stop actions and at end-of-track. """ - self.backend.core_queue.put({ - 'to': 'frontend', - 'command': 'stopped_playing', - 'track': self.current_track, - 'stop_position': self.time_position, - }) + if self.current_track is not None: + self.backend.core_queue.put({ + 'to': 'frontend', + 'command': 'stopped_playing', + 'track': self.current_track, + 'stop_position': self.time_position, + })