Module media_transport
Expand description
MediaTransport: what is playing and the controls that steer it, as one band of real controls —
art and song, like and lyrics, shuffle, previous, play/pause, next and repeat over the scrubber,
the queue and the volume.
Playback belongs to the window, not to the page open, so the transport is meant for
NavShell::bottom_band: it spans the window under every
column.
The app’s player is the one truth. It declares what plays through a TransportFeed
(TransportFeed::show, cheap when nothing changed) and hands in the actions the controls
invoke (TransportActions): each one runs one of the app’s own resource actions, as an agent
invoking it would, so what the person presses is never a callback beside the app’s actions. A
control the app hands no action for is not there. What only changes what the window shows (the
queue, the lyrics, the compact form’s More menu, the art) and a swipe across the band come back
as TransportEvents (TransportFeed::take_events). The transport keeps nothing of its own
but where the knob is while a finger or the pointer holds it.
Two forms, chosen by width: wide puts the song on the left, the transport centred over the
scrubber, the queue and volume on the right; compact (narrower than two large media cards)
puts the song beside previous, play and next, with the volume and a More button the app answers
with a menu. The volume is reachable at every width, a slider where it fits and else a speaker
button whose popover holds it; the art opens what plays when the app says what that is
(TransportState::opens), and a horizontal swipe across the band skips a song. A control the
app leaves out (a local file can’t be liked) is not there at all, and everything rests disabled
while nothing can play.
let transport = TransportFeed::new();
let actions = TransportActions { play_pause: Some(play_pause), ..TransportActions::default() };
let shell = NavShell::new().bottom_band(Box::new(MediaTransport::new(&transport, actions)));
// each sync:
transport.show(TransportState { title, playing, .. });
for event in transport.take_events() { /* show the queue, the lyrics, a menu */ }Structs§
- Media
Transport - The media transport: see the module docs.
- Transport
Actions - The app’s actions the transport’s controls invoke, each through the
resource/action door. A control whose action is
Noneis left out. - Transport
Feed - Where an app declares what plays and takes what the person asked for. Clones share one transport.
- Transport
State - What plays, as the app’s player has it: everything the transport shows.
- Transport
Triggers - What each of a band’s controls does, as a view gives them: the band reports what the person
pressed, and the view’s action does the rest. A control the view gives
Noneis left out.
Enums§
- Transport
Art - The song’s art in the transport.
- Transport
Event - What the person asked for that changes what the window shows, rather
than what plays (
TransportActions), and the swipe across the band. - Transport
Repeat - What a repeat control repeats.