Class “Video”

Object > NativeObject > Widget > Video

A widget that plays a video from an URL.

Video on Android
Android
Video on iOS
iOS
Constructor public
Singleton No
Namespace tabris
Direct subclasses None
JSX support Element: <Video/>
Parent element: <Composite/> and any widget extending Composite
Child elements: None
Text content: Not supported

Example

import {Video, contentView} from 'tabris';

new Video({
  width: 160, height: 90,
  url: "resources/video.mp4"
}).appendTo(contentView);

See also:

JS Creating a Video widget

Constructor

new Video(properties?)

Parameter Type Optional Description
properties Properties<Video> Yes Sets all key-value pairs in the properties object as widget properties.

Methods

pause()

Pauses the video. state changes to pause and speed to 0. Has no effect when state is not play.

Returns void

play(speed?)

Starts playing the video, state changes to play. Has no effect unless the current state is either pause or ready.

Parameter Type Optional Description
speed number Yes Desired playback speed. If the given speed is not supported by the platform or video, the actual playback speed will be 1 - i.e. the natural speed of the video.

Returns void

seek(position)

Attempts to change the position to the given time index. Success depends on the currently loaded video. Has no effect if the current state is empty or fail.

Parameter Type Optional Description
position number No Desired position in milliseconds.

Returns void

Properties

autoPlay

If set to true, starts playing the video as soon as the state changes from open to ready.

Type boolean
Default true
Settable Yes
Change events Yes

controlsVisible

If set to true, overlays the video with a native UI for controlling playback.

Type boolean
Default true
Settable Yes
Change events Yes

duration

Returns the full length of the current video in milliseconds.

Type number
Settable No
Change events Yes

position

Returns the current playback position in milliseconds. This property does not trigger any change events.

Type number
Settable No
Change events Yes

speed

Returns the current playback speed. The value 1 represents the natural speed of the video. When the state of the widget is not play this property always has the value 0.

Type number
Settable No
Change events Yes

state

The current state of the widget.

Type 'empty' | 'open' | 'ready' | 'play' | 'stale' | 'pause' | 'finish' | 'fail'
Default 'empty'
Settable No
Change events Yes

url

The URL of the video to play. Setting this property to any non-empty string changes the state to open and the video starts loading. Setting this property to an empty string unloads the current video and the state returns to empty.

Type string
Settable Yes
Change events Yes

Change Events

urlChanged

Fired when the url property has changed.

Parameter Type Description
value string The new value of url.

controlsVisibleChanged

Fired when the controlsVisible property has changed.

Parameter Type Description
value boolean The new value of controlsVisible.

autoPlayChanged

Fired when the autoPlay property has changed.

Parameter Type Description
value boolean The new value of autoPlay.

speedChanged

Fired when the speed property has changed.

Parameter Type Description
value number The new value of speed.

positionChanged

Fired when the position property has changed.

Parameter Type Description
value number The new value of position.

durationChanged

Fired when the duration property has changed.

Parameter Type Description
value number The new value of duration.

stateChanged

Fired when the state property has changed.

Parameter Type Description
value string The new value of state.