Add radio now-playing metadata polling and readonly props
This commit is contained in:
@@ -29,6 +29,8 @@ DEFAULT_PARAMS: dict = {
|
||||
"mediaChannel": "stereo",
|
||||
"mediaEffect": "off",
|
||||
"mediaEffectValue": 50,
|
||||
"stationName": "",
|
||||
"nowPlaying": "",
|
||||
"facing": 0,
|
||||
"emitRange": 10,
|
||||
}
|
||||
@@ -39,6 +41,8 @@ PARAM_KEYS: tuple[str, ...] = (
|
||||
"mediaChannel",
|
||||
"mediaEffect",
|
||||
"mediaEffectValue",
|
||||
"stationName",
|
||||
"nowPlaying",
|
||||
"facing",
|
||||
"emitRange",
|
||||
)
|
||||
@@ -61,7 +65,10 @@ PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
||||
"valueType": "number",
|
||||
"tooltip": "Amount for the selected effect.",
|
||||
"range": {"min": 0, "max": 100, "step": 0.1},
|
||||
"visibleWhen": {"mediaEffect": "!off"},
|
||||
},
|
||||
"stationName": {"valueType": "text", "tooltip": "Detected station name from stream metadata."},
|
||||
"nowPlaying": {"valueType": "text", "tooltip": "Detected current track/title from stream metadata."},
|
||||
"facing": {
|
||||
"valueType": "number",
|
||||
"tooltip": "Facing direction in degrees used for directional emit.",
|
||||
|
||||
@@ -59,6 +59,9 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
|
||||
if not (0 <= effect_value <= 100):
|
||||
raise ValueError("mediaEffectValue must be between 0 and 100.")
|
||||
next_params["mediaEffectValue"] = round(effect_value, 1)
|
||||
# Read-only metadata fields are server-managed and cannot be client-edited.
|
||||
next_params["stationName"] = str(item.params.get("stationName", "")).strip()[:160]
|
||||
next_params["nowPlaying"] = str(item.params.get("nowPlaying", "")).strip()[:200]
|
||||
|
||||
try:
|
||||
facing = float(next_params.get("facing", item.params.get("facing", 0)))
|
||||
|
||||
Reference in New Issue
Block a user