Add a player widget, and let a slider be drawn as a fader
The player is the one tile that both reads and publishes, so it has two bindings: it shows a `record` describing what is playing — title, artist, album, status, and position and duration in seconds — and publishes transport words back to one `str` message (`toggle`, `next`, `prev`, `seek:<seconds>`). Those are a streamer's own vocabulary rather than this app's, which is what lets one tile drive whatever is on the other end. The position counts forward in the browser between readings, so the bar moves at one second while the device behind it is polled at whatever rate suits it; every reading that arrives is taken as the truth and the count restarts there. That is also why this is one record rather than five messages — a tile drawn from five would redraw itself five times, and show a new title against the old duration in between. Being both is why `INPUT_WIDGETS` does not gain it: what that set means is "the message this widget publishes is its only binding", which is exactly what a player is not. Its reading is checked the usual way and its `target` separately. The fader beside it needed nothing new. `ui/core` has had `orientation` on the slider all along and all three looks draw it; only the widget never passed it, so a volume control — the one thing reached for without looking, where up is louder — could not be a column. Now it can, and the tile's height is the track.
This commit is contained in:
@@ -252,6 +252,20 @@ def test_a_media_widget_binds_media_and_nothing_else():
|
||||
)
|
||||
|
||||
|
||||
def test_a_player_reads_a_track_and_publishes_words():
|
||||
WidgetDef(
|
||||
id="p",
|
||||
type="player",
|
||||
config={"message": "music.track", "dtype": "record", "target": "music.command"},
|
||||
)
|
||||
# One reading, not five: a title, a position and a duration arrive together
|
||||
# or the tile redraws itself a piece at a time.
|
||||
with pytest.raises(ValueError):
|
||||
WidgetDef(
|
||||
id="p", type="player", config={"message": "music.title", "dtype": "str"}
|
||||
)
|
||||
|
||||
|
||||
def test_a_bar_nests_a_second_number():
|
||||
WidgetDef(
|
||||
id="b",
|
||||
|
||||
Reference in New Issue
Block a user