Class clove::MediaPlayer

class clove::MediaPlayer : public clove::Widget

A base class for media player widgets.

This is an abstract class. Use one of the subclasses.

Note: This interface provides actions and events for typical usage. For other scenarios, use nativeNode() for retrieving the <audio> or <video> html dom node. They provide a more powerful api.

Subclassed by clove::AudioPlayer, clove::VideoPlayer

Public Functions

autoPlay()

If to automatically start playback as soon as possible.

setAutoPlay(value)

Setter for autoPlay().

Parameters
  • value: The new value.

showControls()

If to show user controls for play, pause and more.

setShowControls(value)

Setter for showControls().

Parameters
  • value: The new value.

currentMediaPosition()

The current media playback position in seconds.

setCurrentMediaPosition(value)

Setter for currentMediaPosition().

Parameters
  • value: The new value.

loop()

If to playback in an endless loop.

setLoop(value)

Setter for loop().

Parameters
  • value: The new value.

muted()

If to mute the audio playback.

setMuted(value)

Setter for muted().

Parameters
  • value: The new value.

preload()

If to begin loading the media data as soon as possible.

setPreload(value)

Setter for preload().

Parameters
  • value: The new value.

volume()

The audio playback volume between 0.0 and 1.0.

setVolume(value)

Setter for volume().

Parameters
  • value: The new value.

source()

The media source URL.

setSource(value)

Setter for source().

Parameters
  • value: The new value.

duration()

The duration of the loaded media source in seconds.

hasEnded()

If the playback has ended (i.e. reached the end).

isPaused()

If the playback is logically paused.

This does not return true just when loading stalls.

nativeNode()

Returns the native html dom node.

play()

Starts playback.

pause()

Pauses playback.

OnLoadingAborted

Triggered when the media loading aborted for some reasons (e.g. network errors).

This is a clove.Event instance. See Manual for details.

OnReadyForPlayback

Triggered when there are enough data for starting playback.

This is a clove.Event instance. See Manual for details.

OnDurationChanged

Triggered when the playback duration changed.

See also duration().

This is a clove.Event instance. See Manual for details.

OnHasEnded

Triggered when the playback has ended.

See also hasEnded().

This is a clove.Event instance. See Manual for details.

OnIsPaused

Triggered when the playback logically paused.

This is not triggered when loading stalls.

This is a clove.Event instance. See Manual for details.

OnIsPlaying

Triggered when the playback logically starts.

This is not triggered when loading has stalled and resumes.

This is a clove.Event instance. See Manual for details.

declareProperty(k, defaultV)

Declares a widget property.

This is intended to be called only from inside the widget constructor.

Read the Manual about widget properties and custom widgets.

Parameters
  • k: The widget property name.

  • defaultV: The default value.

getProperty(k)

General-purpose getter for widget properties.

Typically used for handling properties, which do not directly belong to the widget class but which are helpers for external aspects (e.g. a row index for positioning in a grid).

The known ones have a dedicated getter and setter, i.e. x.name() for `x.getProperty(‘name’) andx.setName(v)` respectively.

Read the Manual about widget properties.

Parameters
  • k: The widget property name.

setProperty(k, v)

General-purpose setter for widget properties.

See getProperty().

Parameters
  • k: The widget property name.

  • v: The new value.

bindProperty(k, vb)

Binds a DataBinding to a property. Read Manual for details about data bindings.

Parameters
  • k: The widget property name.

  • vb: The clove.DataBinding to bind. May be ‘undefined’ for just unbinding.

init(rootNameScope)

Initializes the widget.

Never override this method in custom widgets. See doresize().

Intended for usage by the infrastructure; never call this method directly.

Parameters
  • rootNameScope: The root namescope to add this widget to.

doinit()

Executes late widget initialization (i.e. after properties are applied).

This is used for initialization steps which need the properties to be applied already. See also doinitEarly().

Override this method in custom widgets.

Intended for usage by the infrastructure; never call this method directly.

doinitEarly()

Executes early widget initialization (i.e. before properties are applied).

This is used for initialization steps which need to run before property values are applied. See also doinit().

Override this method in custom widgets.

Intended for usage by the infrastructure; never call this method directly.

resize()

Applies the new widget size to internal content.

Never override this method in custom widgets. See doresize().

This function is typically called from the parent widget when the size has been changed.

doresize()

Corrects alignments of internal elements according to the new widget size.

Override this method in custom widgets.

Never call this method directly. See resize().

relayout()

Notifies the parent widget that a new geometry is required.

This will eventually lead to a resizing according to clove::Widget::getPreferredWidth (et al).

This function is typically called from within the widget implementation when the content changed and from child widgets.

focus()

Sets the focus to this widget.

isAlive()

Checks if the widget is still alive (i.e. mounted somewhere in the dom tree).

computeMinimalWidth()

Computes the minimal width in pixel this widget needs to have.

Override this method for geometry measurement in custom widgets.

computePreferredWidth()

Computes the preferred width in pixel this widget needs to have.

Override this method for geometry measurement in custom widgets.

computeMinimalHeightForWidth(w)

Computes the minimal height in pixel this widget needs to have for a given width.

Override this method for geometry measurement in custom widgets.

Parameters
  • w: The width in pixel.

computePreferredHeightForWidth(w)

Computes the preferred height in pixel this widget needs to have for a given width.

Override this method for geometry measurement in custom widgets.

Parameters
  • w: The width in pixel.

getMinimalWidth()

Returns the minimal width in pixel this widget needs to have.

Do not override this method in custom widgets. This method caches geometry and does some other adjustments.

getPreferredWidth()

Returns the preferred width in pixel this widget needs to have.

Do not override this method in custom widgets. This method caches geometry and does some other adjustments.

getMinimalHeightForWidth(w)

Returns the minimal height in pixel this widget needs to have for a given width.

Do not override this method in custom widgets. This method caches geometry and does some other adjustments.

Parameters
  • w: The width in pixel.

getPreferredHeightForWidth(w)

Returns the preferred height in pixel this widget needs to have for a given width.

Do not override this method in custom widgets. This method caches geometry and does some other adjustments.

Parameters
  • w: The width in pixel.

addStyleClass(clss)

Adds the css class clss to this widget.

Parameters
  • clss: A css class name.

removeStyleClass(clss)

Removes the css class clss from this widget.

Parameters
  • clss: A css class name.

isStyleClass(clss)

Checks if this widget contains the css class clss.

Parameters
  • clss: A css class name.

setStyleClassAssigned(clss, assigned)

Sets or unsets the css class clss to this widget.

Parameters
  • clss: A css class name.

  • assigned: If to assign or unassign it.

containingNameScope()

The namescope this widget contains to.

nameScope()

The own namescope (or the namescope it contains to, if this widget does not bring a new one).

remove(removeconfig)

Removes this widget.

Note: This method does not guarantee to remove the widget synchronously, since there might be animations before.

Use clove::Widget::OnDestroyed for continuing after removal.

Parameters
  • removeconfig: The removal configuration (optional and only for exotic cases).

effectivelyEnabled()

If this widget is enabled and not marked as busy (i.e. can interact with the user).

This checks if the parent widgets are enabled and non-busy as well. See also enabled() and busy().

effectiveVisibility()

If this widget and all parent widgets are visible. See also visibility().

childrenWidgets()

List of the children clove::Widget instances.

parentWidget()

The parent clove::Widget.

name()

The name of the widget.

This name can be used for getting the widget instance later on. Read the Manual about namescopes for details.

setName(value)

Setter for name().

Parameters
  • value: The new value.

enabled()

If this widget is marked as enabled (i.e. can interact with the user).

This does not check the parents. See also effectivelyEnabled().

setEnabled(value)

Setter for enabled().

Parameters
  • value: The new value.

styleClass()

Custom css class(es).

setStyleClass(value)

Setter for styleClass().

Parameters
  • value: The new value.

style()

Custom css style string. You should not use that, but styleClass() instead.

setStyle(value)

Setter for style().

Parameters
  • value: The new value.

visibility()

If this widget is visible.

One of clove::Visible, clove::Invisible and clove::InvisibleCollapsed.

See also effectiveVisibility().

setVisibility(value)

Setter for visibility().

Parameters
  • value: The new value.

doStandaloneResizing()

If the widget handles to resize itself as needed.

This is only needed in exotic situations and by the infrastructure.

setDoStandaloneResizing(value)

Setter for doStandaloneResizing().

Parameters
  • value: The new value.

mayFocus()

If the widget can have the keyboard focus.

setMayFocus(value)

Setter for mayFocus().

Parameters
  • value: The new value.

horizontalStretchAffinity()

Numeric value >= 0 which specifies how much this widget would benefit from additional horizontal space.

setHorizontalStretchAffinity(value)

Setter for horizontalStretchAffinity().

Parameters
  • value: The new value.

verticalStretchAffinity()

Numeric value >= 0 which specifies how much this widget would benefit from additional vertical space.

setVerticalStretchAffinity(value)

Setter for verticalStretchAffinity().

Parameters
  • value: The new value.

strictHorizontalSizing()

If the widget is strictly forbidden to get additional horizontal space.

Otherwise there are situations where additional space is assigned even with horizontalStretchAffinity()==0.

setStrictHorizontalSizing(value)

Setter for strictHorizontalSizing().

Parameters
  • value: The new value.

strictVerticalSizing()

If the widget is strictly forbidden to get additional vertical space.

Otherwise there are situations where additional space is assigned even with verticalStretchAffinity()==0.

setStrictVerticalSizing(value)

Setter for strictVerticalSizing().

Parameters
  • value: The new value.

vstretch()

Alias for verticalStretchAffinity().

setVstretch(value)

Setter for vstretch().

Parameters
  • value: The new value.

hstretch()

Alias for horizontalStretchAffinity().

setHstretch(value)

Setter for hstretch().

Parameters
  • value: The new value.

busy()

If the widget is in busy state, typically resulting in a loading animation.

setBusy(value)

Setter for busy().

Parameters
  • value: The new value.

registerBusy()

Sets the widget to busy state and returns a token which helps returning to normal state.

See also unregisterBusy() and busy().

You must not mix this function with direct usage of setBusy()!

unregisterBusy(token)

Drops a token and returns to normal state if no other tokens exist.

Parameters

hasFocus()

If the widget has the keyboard focus.

This also returns true if a child has focus.

innerSize()

Returns inner width and height of this widget.

outerSize()

Returns outer width and height of this widget.

OnDestroyed

Triggered when this widget was removed somehow.

This is a clove.Event instance. See Manual for details.

OnResized

Triggered when this widget was resized.

This is a clove.Event instance. See Manual for details.

OnVisibilityChanged

Triggered when the visibility of this widget changed.

Only direct changes trigger the event, not when the visibility of a predecessor changed.

This is a clove.Event instance. See Manual for details.

OnPropertyChanged

Triggered whenever a property of this widget changed its value.

Note: A few properties are only computed on-demand and don’t trigger this event.

This is a clove.Event instance. See Manual for details.

OnKeyDown

Triggered when a keyboard key went down.

This is a clove.Event instance. See Manual for details.

OnKeyUp

Triggered when a keyboard key came up.

This is a clove.Event instance. See Manual for details.

OnKeyPress

Triggered when a keyboard key was pressed.

Note that this event does not work for all keys in all browsers!

This is a clove.Event instance. See Manual for details.