Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lars Kruse
aura-engine
Commits
501db575
Commit
501db575
authored
Jul 17, 2020
by
David Trattnig
Browse files
Call trackservice plugin for all entry types.
parent
9594fe63
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/core/engine.py
View file @
501db575
...
...
@@ -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
)
...
...
modules/core/events.py
View file @
501db575
...
...
@@ -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
):
...
...
modules/plugins/
api
.py
→
modules/plugins/
trackservice
.py
View file @
501db575
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment