/
/
/
1"""
2MSX Bridge Player Provider for Music Assistant.
3
4Streams music to Smart TVs via the Media Station X (MSX) app.
5Runs an embedded HTTP server that MSX connects to for library browsing,
6playback control, and audio streaming.
7"""
8
9from __future__ import annotations
10
11from typing import TYPE_CHECKING
12
13from music_assistant_models.enums import ProviderFeature
14
15from .constants import CONF_ENABLE_GROUPING, DEFAULT_ENABLE_GROUPING
16from .provider import MSXBridgeProvider
17
18if TYPE_CHECKING:
19 from music_assistant_models.config_entries import ProviderConfig
20 from music_assistant_models.provider import ProviderManifest
21
22 from music_assistant.mass import MusicAssistant
23 from music_assistant.models import ProviderInstanceType
24
25
26async def setup(
27 mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
28) -> ProviderInstanceType:
29 """Initialize provider(instance) with given configuration."""
30 # read the stored value directly: the config's option entries are only resolved
31 # (and its values populated) once the instance exists, which is after this call
32 grouping_enabled = bool(
33 mass.config.get_raw_provider_config_value(
34 config.instance_id, CONF_ENABLE_GROUPING, DEFAULT_ENABLE_GROUPING
35 )
36 )
37 features: set[ProviderFeature] = {ProviderFeature.REMOVE_PLAYER}
38 if grouping_enabled:
39 features.add(ProviderFeature.SYNC_PLAYERS)
40 return MSXBridgeProvider(mass, manifest, config, features)
41