Class MediaControls
VideoView: play/pause, a scrub bar and a position clock — the
bar every player lays over its picture. Everything here drives the view and only the view
(VideoView.setPaused(boolean), VideoView.seek(long, VideoStreamSource.SeekMode),
VideoView.positionMicros()), so it works with a frozen capture, a source with no
soundtrack, and a player the application built itself.
It reads left to right in either direction, by default. The playback cluster inherits
its arrangement from tape decks and the scrub bar advances the way the tape ran; media playback
is the standing exception in every platform's bidi guidance, so this widget declares LTR
for itself when it is built. That is a declaration and not a law: an application that wants the
controls to follow the tree (some platforms do mirror them) calls
setLayoutDirection(null) to inherit, or passes an explicit direction — the same knob
every widget has (see docs/design/direction-axis.md).
Sound, and which half of it is the toolkit's. A mute button and a volume slider are
built in, because a gain on the soundtrack the player already holds is the toolkit's to turn
(MediaPlayer.audio()). By default they appear only while the media can actually sound
(MediaControls.Sound.AUTO) and step aside otherwise, so a silent clip does not carry a dead volume;
setSound(limn.components.MediaControls.Sound) forces them MediaControls.Sound.ON or MediaControls.Sound.OFF. Muting is gain zero and
never a teardown. Everything behind the gain stays the application's: one that opens
its soundtrack lazily, switches audio tracks or offers subtitles turns the built-ins off and
wires its own widgets into the slots.
The slots. addLeading(limn.scene.Widget) places a widget between the play button and the scrub
bar (where players put their volume), addTrailing(limn.scene.Widget) between the scrub bar and the clock,
and setOnRefresh(java.lang.Runnable) gives injected controls a ride on the same heartbeat the built-in ones
update on. setShowPosition(boolean) and setBackdrop(boolean) trim the built-ins.
The bar polls on a timer rather than a ticker, so parked over a paused picture it costs nothing: every write below is guarded, and a frame is only asked for when a number actually moved.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhether the mute button and volume slider are offered. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLeading(Widget widget) Adds a widget between the play button and the scrub bar — where players put their volume.addTrailing(Widget widget) Adds a widget between the scrub bar and the position clock.booleanisMuted()Whether the soundtrack is silenced (gain zero; the stream keeps running).protected voidonLayout()Containers position children here (measure +Widget.layoutBox(float, float, float, float)per child).protected SizeonMeasure(Constraints constraints) Reports the size this widget wants withinconstraints.protected voidWidget's own background/content, in local coordinates.setBackdrop(boolean paint) Whether the bar paints its own translucent panel (default true).Overrides the ink the built-ins write in — the play glyph and the clock.setMuted(boolean newMuted) Gain zero and never a teardown: a mute that closed the stream would cost a decoder flush every time somebody silenced a video for a moment.setOnRefresh(Runnable listener) Runs on every refresh of the built-in controls, so a widget injected throughaddLeading(limn.scene.Widget)/addTrailing(limn.scene.Widget)can update on the same heartbeat instead of arming a timer of its own.setShowPosition(boolean show) Whether the position clock is shown (default true).setSound(MediaControls.Sound mode) Whether the mute button and volume slider are offered (defaultMediaControls.Sound.AUTO).setVolume(float newLevel) Volume in[0, 1], applied as a gain on the soundtrack the player holds; zero also mutes.view()The view these controls drive.floatvolume()The volume unmuting restores, in[0, 1].Methods inherited from class limn.scene.Widget
acceptsTextInput, add, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, clipsChildren, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, hitTest, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onAttached, onCharTyped, onDetached, onFileDrop, onFocusGained, onFocusLost, onKeyEvent, onMouseEvent, onPaintOverlay, onPreedit, overlayPassesPointer, paintChildren, paintOutset, paintWidget, parent, remove, requestFocus, revealInView, scene, sceneToLocalX, sceneToLocalY, setControlSize, setCursor, setEnabled, setFocusable, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, width, x, y
-
Constructor Details
-
MediaControls
-
-
Method Details
-
view
The view these controls drive. -
addLeading
Adds a widget between the play button and the scrub bar — where players put their volume. Order of calls is the order on screen. -
addTrailing
Adds a widget between the scrub bar and the position clock. -
setShowPosition
Whether the position clock is shown (default true). -
setBackdrop
Whether the bar paints its own translucent panel (default true). A host that already draws chrome behind the controls — a glass strip over the picture — turns it off. -
setOnRefresh
Runs on every refresh of the built-in controls, so a widget injected throughaddLeading(limn.scene.Widget)/addTrailing(limn.scene.Widget)can update on the same heartbeat instead of arming a timer of its own. -
setInk
Overrides the ink the built-ins write in — the play glyph and the clock. A bar drawn over someone else's chrome (a glass strip over the picture) sits on a surface the palette knows nothing about, and a theme ink chosen for the theme's own surfaces can land near-black on it.nulls restore the theme's answer. -
setSound
Whether the mute button and volume slider are offered (defaultMediaControls.Sound.AUTO). -
setVolume
Volume in[0, 1], applied as a gain on the soundtrack the player holds; zero also mutes. This is what unmuting restores. -
volume
public float volume()The volume unmuting restores, in[0, 1]. -
setMuted
Gain zero and never a teardown: a mute that closed the stream would cost a decoder flush every time somebody silenced a video for a moment. -
isMuted
public boolean isMuted()Whether the soundtrack is silenced (gain zero; the stream keeps running). -
onMeasure
Description copied from class:WidgetReports the size this widget wants withinconstraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.Resolve the
ControlSizeand theLayoutDirectiononce each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, andI18n.locale()answers it wherever text is resolved. -
onLayout
protected void onLayout()Description copied from class:WidgetContainers position children here (measure +Widget.layoutBox(float, float, float, float)per child). -
onPaint
Description copied from class:WidgetWidget's own background/content, in local coordinates.
-