Components / content
TransportBar builder
A transport for one piece of media.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::content::TransportBar;
Reviewed in transport.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
label(label: impl Into<SharedString>) -> Self
state(state: TransportState) -> Self
position(seconds: f32) -> Self
duration(seconds: f32) -> Self
unknown_duration() -> Self
elapsed(elapsed: impl Into<SharedString>) -> Self
remaining(remaining: impl Into<SharedString>) -> Self
buffered(ranges: impl IntoIterator<Item = BufferedRange>) -> Self
volume(volume: f32) -> Self
muted(muted: bool) -> Self
speeds(speeds: impl IntoIterator<Item = f32>, current: f32) -> Self
step_seconds(seconds: f32) -> Self
seekable(seekable: bool) -> Self
volume_control(available: bool) -> Self
has_previous(has_previous: bool) -> Self
has_next(has_next: bool) -> Self
presentation(state: MediaPresentation, label: impl Into<SharedString>) -> Self
presentation_refused(reason: impl Into<SharedString>) -> Self
on_event(handler: impl Fn(&TransportEvent, &mut Window, &mut App) + 'static) -> Self
Example · transport
fn transport(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(640.0))
.child(
TransportBar::new("scene.transport.playing")
.label("Release walkthrough")
.state(TransportState::Playing)
.position(72.0)
.duration(240.0)
.elapsed("01:12")
.remaining("-02:48")
.buffered([BufferedRange::new(0.0, 156.0)])
.volume(0.7)
.speeds([1.0, 1.5, 2.0], 1.0)
.step_seconds(10.0)
.has_next(true)
.on_event(|_, _, _| {}),
)
.child(
Divider::new()
.id("scene.transport.rule.live")
.label("A stream nobody measured"),
)
.child(
TransportBar::new("scene.transport.live")
.label("Incident bridge")
.state(TransportState::Playing)
.position(1543.0)
.unknown_duration()
.elapsed("25:43")
.volume(0.4)
.on_event(|_, _, _| {}),
)
.child(
Divider::new()
.id("scene.transport.rule.stalled")
.label("Playing and waiting"),
)
.child(
TransportBar::new("scene.transport.stalled")
.label("Release walkthrough")
.state(TransportState::Buffering)
.position(158.0)
.duration(240.0)
.elapsed("02:38")
.remaining("-01:22")
.buffered([BufferedRange::new(0.0, 160.0)])
.volume(0.7)
.muted(true)
.on_event(|_, _, _| {}),
)
.into_any_element()
}