/
/
/
1"""Constants for the WiiM Provider."""
2
3from music_assistant_models.player import PlayerSource
4
5# Player ID prefix to avoid colliding with DLNA (which uses the raw UDN)
6PLAYER_ID_PREFIX = "wiim_"
7
8# Backend markers so either player class can recognise a group member's backend without a
9# circular import, and so detect a cross-backend (mixed) group that must stay read-only.
10BACKEND_OFFICIAL = "official"
11BACKEND_GENERIC = "generic"
12
13# Passive sources detected via current track URI
14SOURCE_AIRPLAY = "airplay"
15SOURCE_SPOTIFY = "spotify"
16SOURCE_UNKNOWN = "unknown"
17SOURCE_NETWORK = "Network"
18
19PASSIVE_SOURCES: dict[str, PlayerSource] = {
20 SOURCE_AIRPLAY: PlayerSource(
21 id=SOURCE_AIRPLAY,
22 name="AirPlay",
23 passive=True,
24 can_play_pause=True,
25 can_next_previous=True,
26 can_seek=True,
27 ),
28 SOURCE_SPOTIFY: PlayerSource(
29 id=SOURCE_SPOTIFY,
30 name="Spotify",
31 passive=True,
32 can_play_pause=True,
33 can_next_previous=True,
34 can_seek=True,
35 ),
36 SOURCE_UNKNOWN: PlayerSource(
37 id=SOURCE_UNKNOWN,
38 name="Unknown",
39 passive=True,
40 can_play_pause=True,
41 can_next_previous=True,
42 can_seek=True,
43 ),
44}
45
46# Input modes from device.supported_input_modes (non-passive, user-selectable)
47# Keys match the display names returned by the SDK
48INPUT_MODE_SOURCES: dict[str, PlayerSource] = {
49 SOURCE_NETWORK: PlayerSource(
50 id="network",
51 name=SOURCE_NETWORK,
52 passive=False,
53 can_play_pause=True,
54 can_next_previous=True,
55 can_seek=True,
56 ),
57 "Bluetooth": PlayerSource(
58 id="bluetooth",
59 name="Bluetooth",
60 passive=False,
61 can_play_pause=True,
62 can_next_previous=False,
63 can_seek=False,
64 ),
65 "Line In": PlayerSource(
66 id="line_in",
67 name="Line In",
68 passive=False,
69 can_play_pause=False,
70 can_next_previous=False,
71 can_seek=False,
72 ),
73 "Optical In": PlayerSource(
74 id="optical",
75 name="Optical In",
76 passive=False,
77 can_play_pause=False,
78 can_next_previous=False,
79 can_seek=False,
80 ),
81 "TV": PlayerSource(
82 id="hdmi",
83 name="TV",
84 passive=False,
85 can_play_pause=False,
86 can_next_previous=False,
87 can_seek=False,
88 ),
89 "Phono In": PlayerSource(
90 id="phono_in",
91 name="Phono In",
92 passive=False,
93 can_play_pause=False,
94 can_next_previous=False,
95 can_seek=False,
96 ),
97}
98
99# Reverse lookup: source ID -> SDK display name for select_source commands
100SOURCE_ID_TO_INPUT_MODE: dict[str, str] = {v.id: k for k, v in INPUT_MODE_SOURCES.items()}
101