/
/
1"""Provider implementation for the MilkDrop Visualizer plugin."""
2
3from __future__ import annotations
4
5from typing import TYPE_CHECKING
6
7from music_assistant.models.plugin import PluginProvider
8
9from .relay import MilkdropRelay
10
11if TYPE_CHECKING:
12 from music_assistant_models.config_entries import ProviderConfig
13 from music_assistant_models.enums import ProviderFeature
14 from music_assistant_models.provider import ProviderManifest
15
16 from music_assistant.mass import MusicAssistant
17
18
19class MilkdropVisualizerProvider(PluginProvider):
20 """Streams waveform frames from playing Sendspin groups to the web frontend."""
21
22 def __init__(
23 self,
24 mass: MusicAssistant,
25 manifest: ProviderManifest,
26 config: ProviderConfig,
27 supported_features: set[ProviderFeature],
28 ) -> None:
29 """Initialize the provider."""
30 super().__init__(mass, manifest, config, supported_features)
31 self._relay = MilkdropRelay(self)
32
33 async def loaded_in_mass(self) -> None:
34 """Register the relay route once fully loaded."""
35 await super().loaded_in_mass()
36 self._relay.setup()
37
38 async def unload(self, is_removed: bool = False) -> None:
39 """
40 Handle unload/close of the provider.
41
42 :param is_removed: True when the provider is removed from the configuration.
43 """
44 await self._relay.close()
45