2020-02-03 16:48:39 +13:00
|
|
|
import pykka
|
|
|
|
|
import logging
|
|
|
|
|
import functools
|
2016-10-30 07:51:39 +13:00
|
|
|
from mopidy.core import CoreListener
|
2019-12-24 13:52:50 +13:00
|
|
|
from .mem import iris
|
2017-02-18 22:04:05 +13:00
|
|
|
|
|
|
|
|
# import logger
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2017-02-17 08:03:11 +13:00
|
|
|
|
2016-10-30 07:51:39 +13:00
|
|
|
|
2020-02-03 16:14:04 +13:00
|
|
|
class IrisFrontend(pykka.ThreadingActor, CoreListener):
|
2016-10-30 07:51:39 +13:00
|
|
|
def __init__(self, config, core):
|
2020-01-05 23:50:35 +00:00
|
|
|
super().__init__()
|
2019-12-24 13:52:50 +13:00
|
|
|
|
2019-12-27 13:34:54 +13:00
|
|
|
# Pass our Mopidy config and core to the IrisCore instance
|
|
|
|
|
iris.config = config
|
|
|
|
|
iris.core = core
|
2016-10-30 07:51:39 +13:00
|
|
|
|
2019-11-19 16:00:08 +13:00
|
|
|
def on_start(self):
|
2019-12-24 13:52:50 +13:00
|
|
|
iris.start()
|
2017-02-18 22:04:05 +13:00
|
|
|
|
2018-03-09 08:23:54 +13:00
|
|
|
def on_stop(self):
|
2019-12-24 13:52:50 +13:00
|
|
|
iris.stop()
|
2018-03-09 08:23:54 +13:00
|
|
|
|
2017-11-21 11:27:34 +13:00
|
|
|
def track_playback_ended(self, tl_track, time_position):
|
2020-08-27 20:58:35 +12:00
|
|
|
if iris.ioloop:
|
|
|
|
|
iris.ioloop.add_callback(
|
|
|
|
|
functools.partial(iris.check_for_radio_update)
|
|
|
|
|
)
|
2016-12-18 11:32:03 +13:00
|
|
|
|
2017-11-21 11:27:34 +13:00
|
|
|
def tracklist_changed(self):
|
2020-08-27 20:58:35 +12:00
|
|
|
if iris.ioloop:
|
|
|
|
|
iris.ioloop.add_callback(
|
|
|
|
|
functools.partial(iris.clean_queue_metadata)
|
|
|
|
|
)
|
2021-10-17 08:13:12 +13:00
|
|
|
|
|
|
|
|
def track_playback_started(self, tl_track):
|
|
|
|
|
if iris.ioloop:
|
|
|
|
|
iris.ioloop.add_callback(
|
|
|
|
|
functools.partial(iris.update_snapcast_meta)
|
|
|
|
|
)
|