Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
501db575
Commit
501db575
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Call trackservice plugin for all entry types.
parent
9594fe63
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/core/engine.py
+5
-1
5 additions, 1 deletion
modules/core/engine.py
modules/core/events.py
+19
-22
19 additions, 22 deletions
modules/core/events.py
modules/plugins/trackservice.py
+2
-1
2 additions, 1 deletion
modules/plugins/trackservice.py
with
26 additions
and
24 deletions
modules/core/engine.py
+
5
−
1
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
)
...
...
This diff is collapsed.
Click to expand it.
modules/core/events.py
+
19
−
22
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
):
...
...
This diff is collapsed.
Click to expand it.
modules/plugins/
api
.py
→
modules/plugins/
trackservice
.py
+
2
−
1
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment