Skip to content
Enact

limestone/VideoPlayer

Provides Limestone-themed video player components.

A standard HTML5 video player for Limestone. It behaves, responds to, and operates like a <video> tag in its support for <source>. It also accepts custom tags such as <infoComponents> for displaying additional information in the title area and <MediaControls> for handling media playback controls and adding more controls.

Example usage:

<VideoPlayer title="Hilarious Cat Video" poster="https://my.cat.videos/boots-poster.jpg">
	<source src="https://my.cat.videos/boots.mp4" type="video/mp4" />
	<infoComponents>A video about my cat Boots, wearing boots.</infoComponents>
	<MediaControls>
		<leftComponents><Button backgroundOpacity="translucent" icon="star" /></leftComponents>
		<rightComponents><Button backgroundOpacity="translucent" icon="notification" /></rightComponents>

		<Button backgroundOpacity="translucent">Add To Favorites</Button>
		<Button backgroundOpacity="translucent" icon="search" />
	</MediaControls>
</VideoPlayer>

To invoke methods (e.g.: fastForward()) or get the current state (getMediaState()), store a ref to the VideoPlayer within your component:

	...

	setVideoPlayer = (node) => {
		this.videoPlayer = node;
	}

	play () {
		this.videoPlayer.play();
	}

	render () {
		return (
			<VideoPlayer ref={this.setVideoPlayer} />
		);
	}

Wrapped with: ui/Slottableui/Slottable.Slottable

Provides support for more advanced video configurations for VideoPlayer.

Custom Video Tag

<VideoPlayer>
  <Video mediaComponent="custom-video-element">
    <source src="path/to/source.mp4" />
  </Video>
</VideoPlayer>

Preload Video Source

<VideoPlayer>
  <Video>
    <source src="path/to/source.mp4" />
    <source src="path/to/preload-source.mp4" slot="preloadSource" />
  </Video>
</VideoPlayer>

Wrapped with: ui/Slottableui/Slottable.Slottable

Properties

Video plays automatically.

Default: false

StringComponentElement

Video component to use.

The default ('video') renders an HTMLVideoElement. Custom video components must have a similar API structure, exposing the following APIs:

Properties:

  • currentTime {Number} - Playback index of the media in seconds

  • duration {Number} - Media's entire duration in seconds

  • error {Boolean} - true if video playback has errored.

  • loading {Boolean} - true if video playback is loading.

  • paused {Boolean} - Playing vs paused state. true means the media is paused

  • playbackRate {Number} - Current playback rate, as a number

  • proportionLoaded {Number} - A value between 0 and 1 representing the proportion of the media that has loaded

  • proportionPlayed {Number} - A value between 0 and 1 representing the proportion of the media that has already been shown

Events:

  • onLoadStart - Called when the video starts to load

  • onPlay - Sent when playback of the media starts after having been paused

  • onUpdate - Sent when any of the properties were updated

Methods:

  • play() - play video

  • pause() - pause video

  • load() - load video

The limestone/VideoPlayerlimestone/VideoPlayer.Video.source property is passed to the video component as a child node.

Default: 'video'

The video source to be preloaded. Expects a <source> node.


The video source to be played.

Any children <source> elements will be sent directly to the mediaComponent as video sources.

See: https://developerhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/source

A player for video limestone/VideoPlayerlimestone/VideoPlayer.VideoPlayerBase.

Properties

The time (in milliseconds) before the control buttons will hide.

Setting this to 0 or null disables closing, requiring user input to open and close.

Default: 5000

Sets the hint string read when focusing the back button.

Default: 'go to previous'

Removes interactive capability from this component. This includes, but is not limited to, key-press events, most clickable buttons, and prevents the showing of the controls.


Amount of time (in milliseconds) after which the feedback text/icon part of the slider's tooltip will automatically hidden after the last action. Setting this to 0 or null disables feedbackHideDelay; feedback will always be present.

Default: 3000

Checks if current time and total time should include the hour.

Default: false

Components placed below the title.

Typically, these will be media descriptor icons, like how many audio channels, what codec the video uses, but can also be a description for the video or anything else that seems appropriate to provide information about the video to the user.


The number of milliseconds that the player will pause before firing the first jump event on a right or left pulse.

Default: 400

The number of seconds the player should skip forward or backward when a "jump" button is pressed.

Default: 30

The number of milliseconds that the player will throttle before firing a jump event on a right or left pulse.

Default: 200

Manually set the loading state of the media, in case you have information that VideoPlayer does not have.


The current locale as a https://toolshttps://tools.ietf.org/html/rfc5646.


ComponentElement

Overrides the default media control component to support customized behaviors.

The provided component will receive the following props from VideoPlayer:

  • initialJumpDelay - Time (in ms) to wait before starting a jump

  • jumpDelay - - Time (in ms) to wait between jumps

  • mediaDisabled - true when the media controls are not interactive

  • no5WayJump - true when 5-way jumping is disabled

  • onClose - Called when cancel key is pressed when the media controls are visible

  • onFastForward - Called when the media is fast forwarded via a key event

  • onJump - Called when the media jumps either forward or backward

  • onJumpBackwardButtonClick - Called when the jump backward button is pressed

  • onJumpForwardButtonClick - Called when the jump forward button is pressed

  • onKeyDown - Called when a key is pressed

  • onNextButtonClick - Called when the next button is pressed

  • onPause - Called when the media is paused via a key event

  • onPlay - Called when the media is played via a key event

  • onPreviousButtonClick - Called when the previous button is pressed

  • onRewind - Called when the media is rewound via a key event

  • onToggleMore - Called when the more components are hidden or shown

  • paused - true when the media is paused

  • spotlightId - The spotlight container Id for the media controls

  • spotlightDisabled - true when spotlight is disabled for the media controls

  • visible - true when the media controls should be displayed

Default: limestone/MediaPlayer.MediaControls

Amount of time (in milliseconds), after the last user action, that the miniFeedback will automatically hide. Setting this to 0 or null disables miniFeedbackHideDelay; miniFeedback will always be present.

Default: 2000

Disable audio for this video.

In a TV context, this is handled by the remote control, not programmatically in the VideoPlayer API.

Default: false

Prevents the default behavior of using left and right keys for seeking.


Prevents the default behavior of playing a video immediately after it's loaded.

Default: false

Boolean

Prevents the default behavior of showing media controls immediately after it's loaded.

Default: false

Boolean

Hides media slider feedback when fast-forward or rewind while media controls are hidden.

Default: false

Removes the mini feedback.

Default: false

Removes the media slider.

Default: false

Removes spinner while loading.


Called when the back button is clicked.


Function

Called when the player's controls change availability, whether they are shown or hidden.

The current status is sent as the first argument in an object with a key available which will be either true or false. (e.g.: onControlsAvailable({available: true}))


Called when the video has been fast forwarded.


Called when the user clicks the JumpBackward button.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called when the user clicks the JumpForward button.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called when the user clicks the next button.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called when the video has been paused.


Called when the video has been played.


Called when the user clicks the previous button.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called when the video has been rewound.


Called when the user is moving the VideoPlayer's Slider knob independently of the current playback position.

It is passed an object with a seconds key (float value) to indicate the current time index. It can be used to update the thumbnailSrc to reflect the current scrub position.


Called when seek is attempted while seekDisabled is true.


Function

Called when seeking outside of the current selection range.

By default, the seek will still be performed. Calling preventDefault() on the event will prevent the seek operation.


Called when the visibility of more components is changed

Event payload includes:

  • type - Type of event, 'onToggleMore'

  • showMoreComponents - true when the components are visible`

  • liftDistance - The distance, in pixels, the component animates `


Called once before the video is forwarded.


Function

Called once before the video is jump backwarded.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called once before the video is jump forwarded.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called once before playing the next video in the playlist.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called once before the video is paused.


Called once before the video is played


Called once before playing the previous video in the playlist.

Is passed a limestone/VideoPlayerlimestone/VideoPlayer.videoStatus as the first argument.


Called once before the video is rewound.


Pauses the video when it reaches either the start or the end of the video during rewind, slow rewind, fast-forward, or slow forward.

Default: false

limestone/VideoPlayer.playbackRateHash

Mapping of playback rate names to playback rate values that may be set.

Default: { fastForward: ['2', '4', '8', '16'], rewind: ['-2', '-4', '-8', '-16'], slowForward: ['1/4', '1/2'], slowRewind: ['-1/2', '-1'] }

Disables seek function.

Note that jump by arrow keys will also be disabled when true.


Array(Number)

A range of the video to display as selected.

The value of selection may either be:

  • null or undefined for no selection,

  • a single-element array with the start time of the selection

  • a two-element array containing both the start and end time of the selection in seconds

When the start time is specified, the media slider will show filled starting at that time to the current time.

When the end time is specified, the slider's background will be filled between the two times.


The video source.

Any children <source> tag elements of limestone/VideoPlayerlimestone/VideoPlayer will be sent directly to the videoComponent as video sources.


Disables spotlight navigation into the component.


The spotlight container ID for the player.

Default: 'videoPlayer'

StringComponentElement

The thumbnail component to be used instead of the built-in version.

The internal thumbnail style will not be applied to this component. This component follows the same rules as the built-in version.


StringObject

Thumbnail image source to show on the slider knob.

This is a standard limestone/Imagelimestone/Image component so it supports all the same options for the src property. If no thumbnailComponent and no thumbnailSrc is set, no tooltip will display.


Enables the thumbnail transition from opaque to translucent.


Title for the video being played.


The time (in milliseconds) before the title disappears from the controls.

Setting this to 0 disables hiding.

Default: 5000

ComponentElement

Video component to use.

The default renders an HTMLVideoElement. Custom video components must have a similar API structure, exposing the following APIs:

Properties:

  • currentTime {Number} - Playback index of the media in seconds

  • duration {Number} - Media's entire duration in seconds

  • error {Boolean} - true if video playback has errored.

  • loading {Boolean} - true if video playback is loading.

  • paused {Boolean} - Playing vs paused state. true means the media is paused

  • playbackRate {Number} - Current playback rate, as a number

  • proportionLoaded {Number} - A value between 0 and 1 representing the proportion of the media that has loaded

  • proportionPlayed {Number} - A value between 0 and 1 representing the proportion of the media that has already been shown

Events:

  • onLoadStart - Called when the video starts to load

  • onUpdate - Sent when any of the properties were updated

Methods:

  • play() - play video

  • pause() - pause video

  • load() - load video

The limestone/VideoPlayerlimestone/VideoPlayer.Video.source property is passed to the video component as a child node.

Default: {@link ui/Media.Media}

Shows media controls.


Hides media controls.


Toggles the media controls.


Returns an object with the current state of the media including currentTime, duration, paused, playbackRate, proportionLoaded, and proportionPlayed.


Programmatically plays the current media. If you call this function during fast forwarding or rewinding, the playback speed will be set to normal.


Programmatically pauses the current media. If you call this function during fast forwarding or rewinding, the playback speed will be set to normal.


Sets the media playback time index.


Step a given amount of time away from the current playback position. Like limestone/VideoPlayerlimestone/VideoPlayer.VideoPlayerBase.seek but relative.


Fast forwards the current media for seeking. This function changes the playback rate. If you call play or pause during fast forwarding, the playback speed will be set to normal.


Rewinds the current media for seeking. This function changes the playback rate. If you call play or pause during rewinding, the playback speed will be set to normal.


Sets the playback speed.


Returns a proxy to the underlying <video> node currently used by the VideoPlayer

A set of playback rates when media fast forwards, rewinds, slow-forwards, or slow-rewinds.

The number used for each operation is proportional to the normal playing speed, 1. If the rate is less than 1, it will play slower than normal speed, and, if it is larger than 1, it will play faster. If it is negative, it will play backward.

The order of numbers represents the incremental order of rates that will be used for each operation. Note that rates can be expressed as decimals, strings, and fractions. (e.g.: 0.5, '0.5', '1/2').

Required PropertyfastForward
any[]

An array of playback rates when media fast forwards


Required Propertyrewind
any[]

An array of playback rates when media rewinds


Required PropertyslowForward
any[]

An array of playback rates when media slow-forwards


Required PropertyslowRewind
any[]

An array of playback rates when media slow-rewinds

Every callback sent by limestone/VideoPlayerlimestone/VideoPlayer receives a status package, which includes an object with the following key/value pairs as the first argument:

Required Propertytype
String

Type of event that triggered this callback


Required PropertycurrentTime
Number

Playback index of the media in seconds


Required Propertyduration
Number

Media's entire duration in seconds


Required Propertypaused
Boolean

Playing vs paused state. true means the media is paused


Required PropertyplaybackRate
Number

Current playback rate, as a number


Required PropertyproportionLoaded
Number

A value between 0 and 1 representing the proportion of the media that has loaded


Required PropertyproportionPlayed
Number

A value between 0 and 1 representing the proportion of the media that has already been shown