aboutsummaryrefslogtreecommitdiffstats
path: root/solo_tool.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-03 18:49:09 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-03 18:49:09 +0100
commit91cbf23d3acc3e44b333cac95d45575bc7bacb1c (patch)
treed6f336363ce050e3dfb54d2f1d01dbec136104c1 /solo_tool.py
parentd9c8684447654f1b7b4b3b0f25a7a56d42a8f535 (diff)
Added basic event notification capabilities, first event
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)
+