aboutsummaryrefslogtreecommitdiffstats
path: root/solo_tool.py
diff options
context:
space:
mode:
Diffstat (limited to 'solo_tool.py')
-rw-r--r--solo_tool.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/solo_tool.py b/solo_tool.py
index 6581f5e..5e3a1fd 100644
--- a/solo_tool.py
+++ b/solo_tool.py
@@ -3,6 +3,7 @@ import os
from playlist import Playlist
from abcontroller import ABController
from session_manager import SessionManager
+from notifier import Notifier
from player_vlc import Player
class SoloTool:
@@ -11,6 +12,7 @@ class SoloTool:
self._playlist = Playlist(self._playlistCallback)
self._abController = ABController(enabled=False, callback=self._abControllerCallback)
self._sessionManager = SessionManager(self._playlist, self._abController)
+ self._notifier = Notifier()
def _playlistCallback(self, path):
self._player.setCurrentSong(path)
@@ -78,13 +80,19 @@ class SoloTool:
self._sessionManager.saveSession(f)
def play(self):
- self._player.play()
+ self._playerCommand(self._player.play)
def pause(self):
- self._player.pause()
+ self._playerCommand(self._player.pause)
def stop(self):
- self._player.stop()
+ self._playerCommand(self._player.stop)
+
+ def _playerCommand(self, f):
+ playing = self.isPlaying()
+ f()
+ if playing != self.isPlaying():
+ self._notifier.notify(Notifier.PLAYING_STATE_EVENT)
def isPlaying(self):
return self._player.isPlaying()
@@ -101,3 +109,6 @@ class SoloTool:
def setPlaybackVolume(self, volume):
self._player.setPlaybackVolume(volume)
+ def registerPlayingStateCallback(self, callback):
+ self._notifier.registerCallback(Notifier.PLAYING_STATE_EVENT, callback)
+