<video/>

Embeds a video player

<video/> is a General Operator component that renders an embedded video.

Attributes and Properties

Attributes for <video>

Other (7)

number. Default value: 16 / 9. Aspect ratio (width / height) for the video player.

keyword. How to size the video player.

ValueDescription
block (default)Display as a block element on its own line.
inlineRender inline with surrounding text.

keyword. Horizontal alignment of the video within its container.

ValueDescription
center (default)Center the video horizontally.
leftAlign the video to the left edge.
rightAlign the video to the right edge.

keyword. Named size preset for the video player.

ValueDescription
tinyAbout 1/12 the full width.
smallAbout 30% of the full width.
mediumAbout half the full width.
largeAbout 70% of the full width.
full (default)The full available width.
source

text. URL of the video source.

componentSize. Explicit width of the video player (overrides size).

text. YouTube video ID to embed.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <video name="v">

Other (17)
$v.aspectRatio

number. The aspect ratio (width / height) of the video player.

$v.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$v.displayMode

text. How to size the video player.

$v.duration

number. The total duration of the video in seconds.

$v.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$v.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$v.fractionWatched

number. Fraction of the video the viewer has watched (0 to 1).

$v.hidden

boolean. Whether this component is hidden from the rendered output.

$v.horizontalAlign

text. Horizontal alignment of the video within its container.

$v.secondsWatched

number. Total seconds the viewer has watched.

$v.shortDescription

text. A short accessibility description of the video.

$v.size

text. The size of the video player.

$v.source

text. URL of the video source.

$v.state

text. The video's current playback state (e.g. playing, paused).

$v.time

number. The current playback time in seconds.

$v.width

componentSize. The display width of the video player.

$v.youtube

text. YouTube video ID to embed.

Common to all components (4)
$v.doenetML

text. The DoenetML source code that produced this component.

$v.hide

boolean. Whether to hide this component from the rendered output.

$v.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$v.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Default <video/> embed

The video at the youtube website ending in “B7UmUX68KtE” is embedded into the page with the youtube attribute. Note that only the portion of the url following the equals sign is required.


Example: Play <video/> when question answered

The video at the youtube website ending in “B7UmUX68KtE” is triggered to play automatically with a <callAction> when the correct answer is provided.


Example: Give credit based on fraction watched

The student is awarded credit for <answer> v1Credit based on the fractionWatched property of the named <video/> component. This “answer” is submitted automatically with a <callAction> employing the submitAnswer action.

Attribute Examples

Attribute Example: width

The width attribute specifies the absolute width of the video. Doenet determines the size category that corresponds to that width and sizes the video accordingly.


Attribute Example: size

The size attribute specifies one of 5 size categories for the <video/>: tiny, small, medium, large, or full.


Attribute Example: aspectRatio

The aspectRatio attribute allows for customization of the video embed’s default proportions.


Attribute Example: displayMode

The displayMode attribute affects how the <video/> is positioned on screen. The default mode is “block”, which renders the video centered on screen. The available modes are inline, and block.


Attribute Example: horizontalAlign

The horizontalAlign attribute specifies the horizontal position on-screen for the default block-mode style video. Valid values are left, center, and right, with a default of center.


Attribute Example: youtube

The video at https://www.youtube.com/watch?v=B7UmUX68KtE is embedded into the page with the youtube attribute. Note that only the portion of the url following the equals sign is required.

Action Examples

Action Example: playVideo

The playVideo action can be triggered with a <callAction> component.


Action Example: pauseVideo

The pauseVideo action can be triggered with a <callAction> component.

Property Examples

Property Example: Attributes as properties

The above listed <video/> attributes are also accessible as properties.


The <video/> component has several properties related to viewing behavior as shown above. The secondsWatched and fractionWatched properties are only updated once the <video/> has been paused once.