Displays a video.

Video allows playback of video from file or stream through its properties File and Url respectively. It is similar to Image; they share the properties StretchMode, StretchDirection and ContentAlignment and they work in the same way for both classes.

Useful properties

Video comes with a set of properties that can be used to configure it or control it, in addition to the properties shared with Image:

  • Volume: range from 0.0 to 1.0, default is 1.0
  • Duration: the duration of the video in seconds
  • Position: the current position of the video in seconds
  • IsLooping: a bool specifying if the video should loop or not, default is false

Useful triggers that can be used with Video

<Video>
    <WhilePlaying />    <!-- Active while the video is playing -->
    <WhilePaused />     <!-- Active while the video is paused -->
    <WhileCompleted />  <!-- Active while the video is done playing -->
    <WhileLoading />    <!-- Active while the video is loading -->
    <WhileFailed />     <!-- Active if the video failed to load or an error occured -->
</Video>

Useful actions that can be used to control Video

Fuse comes with a set of actions that can be used to control video playback. They all have a common Target property that specifies which Video element they control.

<Pause />                   <!-- Pauses playback, leaving the current position as-is -->
<Stop />                    <!-- Stops playback and returns to the beginning of the video -->
<Resume />                  <!-- Resumes playback from the current position -->

Supported formats

Video is implemented by using the videodecoder provided by the export target and therefore supports whatever the platform supports. Be aware that Windows, OS X, Android and iOS might not share support for some formats

Playing from the local file system

Videos can also be played from the local file system of the device the app is running on. This can be done by prepending file:// to the absolute path of the video:

<Video File="file:///data/data/com.fuse.app/video.mp4" />

Notice the three slashes at the start. This is due to unix file system paths always beginning with a /

Example

The following example shows how to play a video, display its playback progress using ProgressAnimation, and pause/resume the video using the Pause and Resume animators.

<DockPanel>
    <Video ux:Name="video" Dock="Fill" File="fuse_video.mp4" IsLooping="true" StretchMode="UniformToFill">
        <ProgressAnimation>
            <Change progressBar.Width="100" />
        </ProgressAnimation>
    </Video>
    <Rectangle ux:Name="progressBar" Dock="Bottom" Fill="#f00" Width="0%" Height="10" />
    <Grid Dock="Bottom" ColumnCount="2" RowCount="1">
        <Button Text="Play">
            <Clicked>
                <Resume Target="video" />
            </Clicked>
        </Button>
        <Button Text="Pause">
            <Clicked>
                <Pause Target="video" />
            </Clicked>
        </Button>
    </Grid>
</DockPanel>

Location

Namespace
Fuse.Controls
Package
Fuse.Controls.Video 1.9.0

Interface of Video

getDuration() js

Gets the duration of the Video in seconds. getDuration will return 0 until the video has initialized.

pause() js

Pauses playback, leaving the current position as-is.

resume() js

Resumes playback from the current position.

Scale9Margin : float4 ux

For StretchMode="Scale9" this defines the four margins that split the video into 9-sections for scaling.

stop() js

Stops playback and returns to the beginning of the video.

StretchMode : StretchMode ux

Specifies how the size of the video element is calculated and how the video is stretched inside it.

Url : string ux

A Url describing an http video stream resource to be played.

Inherited from Panel

Color : float4 ux

The background color of the panel. This property is a shortcut for setting the Background property to a SolidColor brush. Supports being set using a float4 notation, or hexadecimal values(f.ex #FF00AA)

IsFrozen : bool ux

When true the panel is in a frozen state. This means: - layout of the children is blocked - child invalidation does not invalidate this panel - the visual drawing is captured once and used for all future drawing

Inherited from LayoutControl

Inherited from Control

Inherited from Element

ActualPosition : float2 uno

The position of the element, the position of its top-left corner to the top-left corner in the parent.

Anchor : Size2 ux

A point within the element to treat as its "epicenter".

Aspect : float ux

The aspect ratio that an element must fulfill in layout.

Offset : Size2 ux

Offets the position of the element after all other layout has been applied.

Inherited from Visual

bringIntoView() js

Requests that this visual be brought into the visible are of the screen. Typically a containing ScrollView will scroll to ensure it is visible.

Children : IList of Node ux

The children of the visual. All nodes placed inside the visual in UX markup are assigned to this list. The order of Visuals this list determines the order of layout. The Z-order of the children is by default equal to this order, but can be manipulated separately using methods like BringToFront and SendToBack.

InvalidateVisual uno

Indicates the visual for this node has changed. This allows the root-level node to know that it must draw, and any caching that it must invalidate the cache for this node.

InvalidateVisualComposition uno

Indicates the composition of the visual has changed, but that the visual drawing itself is still valid (for example a position change).

IsEnabled : bool ux

Whether this node is currently interactable. Disabled visuals do not receive input focus. However, they can still be visible and block hit test for underlaying objects.

IsLocalVisible : bool uno

Returns whether this visual is visible without concern for whether an ancestor visual is hidden or collapsed.

IsVisible : bool uno

Returns whether this visual is currently visible. Will return false if any of the ancestor visuals are hidden or collapsed. This property can not be used to check whether a visual is hidden because it is occluded by another visual, or is outside the view but otherwise visible.

Parameter : string ux

The parameter data for this visual, encoded as JSON, provided by a router if this visual represents a navigation page.

SnapToPixels : bool ux

Whether to snap the result of layout of this visual to physical device pixels.

ZOffset : float ux

Specifies a Z-Offset, visuals with higher values are in front of other visuals.

Inherited from Node

ContextParent : Node uno

The context parent is the semantic parent of this node. It is where non-UI structure should be resolved, like looking for the DataContext, a Navigation, or other semantic item.

FindNodeByName(Selector, Predicate<Node> (Node)) : Node uno

Finds the first node with a given name that satisfies the given acceptor. The serach algorithm works as follows: Nodes in the subtree are matched first, then it matches the nodes in the subtrees ofthe ancestor nodes by turn all the way to the root. If no matching node is found, the function returns null.

IsRootingStarted : bool uno

Whether rooting of this node has started. Note that even if this property returns true, rooting may not yet be completed for the node. See also IsRootingCompleted.

Name : Selector ux

Run-time name of the node. This property is automatically set using the ux:Name attribute.

OnRooted uno

If you override OnRooted you must call base.OnRooted() first in your derived class. No other processing should happen first, otherwise you might end up in an undefined state.

Inherited from PropertyObject

Inherited from object

Attached UX Attributes

Items (attached by Each) : object ux

The item collection that will be used to populate this visual.

MatchKey (attached by Each) : string ux

Shorthand for setting the MatchKey property on the implicit Each created when using the Items attached property.

Column (attached by Grid) : int ux

The index of the column the element occupies while in a Grid. If not set, the grid will place the element in a cell according to its position in the child list.

Row (attached by Grid) : int ux

The index of the row the element occupies while in a Grid. If not set, the grid will place the element in a cell according to its position in the child list.

GlobalKey (attached by Resource) : string ux

The ux:Global attribute creates a global resource that is accessible everywhere in UX markup.

Implemented Interfaces

IScriptObject uno

Interface for objects that can have a script engine representation