Skip to content
Snippets Groups Projects
Commit 501db575 authored by David Trattnig's avatar David Trattnig
Browse files

Call trackservice plugin for all entry types.

parent 9594fe63
No related branches found
No related tags found
No related merge requests found
......@@ -314,6 +314,10 @@ class SoundSystem():
self.logger.info("Clear Queue Response: " + res)
self.disable_transaction()
Thread(target=clean_up).start()
# Filesystem meta-changes trigger the event via Liquidsoap
if not entry.channel in ChannelType.FILESYSTEM.channels:
self.on_play(entry)
......@@ -323,7 +327,7 @@ class SoundSystem():
when some entry is actually playing.
Args:
source (String): The URI of the media source currently being played
source (String): The `Entry` or URI or of the media source currently being played
"""
self.event_dispatcher.on_play(source)
......
......@@ -26,14 +26,14 @@ from modules.plugins.monitor import AuraMonitor
from modules.core.state import PlayerStateService
from modules.plugins.api import TrackserviceHandler
from modules.plugins.trackservice import TrackserviceHandler
class EventBinding():
"""
A binding between the event dispatcher and some event handler.
This allows you to subscribe to events in this way:
It allows you to subscribe to events in a chained way:
```
binding = dispatcher.attach(AuraMonitor)
......@@ -66,7 +66,7 @@ class EventBinding():
class EngineEventDispatcher():
"""
Performs execution of handlers for engine events.
Executes handlers for engine events.
"""
logger = None
config = None
......@@ -90,18 +90,13 @@ class EngineEventDispatcher():
self.soundsystem = soundsystem
self.scheduler = scheduler
self.player_state = PlayerStateService(self.config)
# self.api_handler = ApiHandler(self.config)
# self.monitoring = Monitoring(self.config, self.soundsystem)
binding = self.attach(AuraMonitor)
binding.subscribe("on_boot")
binding = self.attach(TrackserviceHandler)
binding.subscribe("on_play")
def attach(self, clazz):
"""
Creates an intance of the given Class.
......@@ -158,35 +153,37 @@ class EngineEventDispatcher():
self.logger.debug("on_boot(..)")
self.call_event("on_boot", None)
# self.monitoring.on_boot()
def on_ready(self):
"""
Called when the engine is booted and ready to play.
"""
self.logger.debug("on_initialized(..)")
self.logger.debug("on_ready(..)")
self.scheduler.on_ready()
def on_play(self, source):
"""
Event Handler which is called by the soundsystem implementation (i.e. Liquidsoap)
when some entry is actually playing.
when some entry is actually playing. Note that this event resolves the source URI
and passes an `PlaylistEntry` to event handlers.
Args:
source (String): The URI of the media source currently being played
source (String): The `Entry` or URI or of the media source currently being played
"""
self.logger.debug("on_play(..)")
self.logger.info(SU.pink("Source '%s' started playing" % source))
try:
self.player_state.store_trackservice_entry(source)
# self.player_state.get_current_entry(source)
except NoActiveEntryException:
self.on_idle()
self.call_event("on_initialized", None)
entry = None
if isinstance(source, str):
try:
self.logger.info(SU.pink("Source '%s' started playing. Resolving ..." % source))
entry = self.player_state.resolve_entry(source)
except NoActiveEntryException:
self.logger.error("Cannot resolve '%s'" % source)
else:
entry = source
self.call_event("on_play", entry)
def on_stop(self, entry):
......
......@@ -22,7 +22,7 @@ import logging
class TrackserviceHandler():
"""
ApiHandler is in charge of external API calls
Sends the trackservice entry to the `engine-api` REST endpoint.
"""
logger = None
config = None
......@@ -43,6 +43,7 @@ class TrackserviceHandler():
Some track started playing.
"""
self.logger.info("::: CALLED TRACKSERVICE HANDLER :::")
self.logger.info("PLAYING: %s <<< " % (str(entry)))
self.store_trackservice(entry)
self.store_schedule(entry)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment