You are here: Creating a Video Using a Constructor: kony.ui.Video

Video Widget

The Video widget helps to play the video files captured using the device's camera, videos from the app resources, and from the servers/ websites by streaming data within a form. The Video widget can be added only to the FlexContainer, FlexScrollContainer, and FlexForm.

Following are a few real-time use cases of Video widget:

Widgets are normally added to your Kony application using Kony Visualizer, but can also be added from code. For general information on using widgets in Visualizer, see Designing an Application in the Kony Visualizer User Guide.

For general information on the Video widget see the Video topic in the Kony Visualizer User Guide.

This widget supports drag and drop of videos for iOS 11 on iPad.

The Video widget capabilities can be broadly categorized into the following:

Layout

 
PropertiesDescription
anchorPoint Specifies the anchor point of the widget bounds rectangle using the widget's coordinate space.
bottom Determines the bottom edge of the widget and is measured from the bottom bounds of the parent container.
centerX Determines the center of a widget measured from the left bounds of the parent container.
centerY This property determines the center of a widget measured from the top bounds of the parent container.
containerWeight Specifies percentage of width to be allocated by its parent widget.
height Determines the height of the widget and measured along the y-axis.
left Determines the lower left corner edge of the widget and is measured from the left bounds of the parent container.
maxHeight Specifies the maximum height of the widget and is applicable only when the height property is not specified.
maxWidth Specifies the maximum width of the widget and is applicable only when the width property is not specified.
minHeight Specifies the minimum height of the widget and is applicable only when the height property is not specified.
minWidth Specifies the minimum width of the widget and is applicable only when the width property is not specified.
right Determines the lower right corner of the widget and is measured from the right bounds of the parent container.
top Determines the top edge of the widget and measured from the top bounds of the parent container.
width Determines the width of the widget and is measured along the x-axis.
zIndex Specifies the stack order of a widget.
 
EventsDescription
doLayout Used to set the layout properties of child widgets in the relation to self and peer widgets whose layout is not yet performed.
  

Video Controls

Methods

Description
getBufferPercentage Returns the amount of the video buffered or played so far in percentage (0-100).
getCurrentPosition Returns the playing time of the current position of the video.
getDuration Returns the duration of the video playing currently.
isPlaying Returns whether or not the video is playing.
pause Pauses the video that is playing.
play Plays the video.
resume Resumes play of a video that is paused.
seekTo Plays the video from a specific time.
setSource Allows you to modify the video source.
stop Stops the video that is playing.
 
PropertiesDescription
controls Specifies whether to display the video controls or not.
videoGravity Specifies how to render a video content inside the widget.
volumeSpecifies the current volume of the audio of the video.
 

3D Touch

MethodsDescription
registerForPeekandPop Registers a widget to enable 3D Touch peek and pop gestures.
setOnPeek Sets and overrides the existing onPeekCallback for the widget.
setOnPop Overrides the existing onPopCallback for the widget.
unregisterForPeekandPop Unregisters a widget from 3D Touch peek and pop gestures.

 

User Input Handling

MethodsDescription
addGestureRecognizer Allows you to set a gesture recognizer for a specified gesture for a specified widget.
removeGestureRecognizer Allows you to remove the specified gesture recognizer for the specified widget.
setGestureRecognizer Allows you to set a gesture recognizer for a specified gesture for a specified widget.
 
EventsDescription
onScrollWidgetPosition Invoked by the platform when the widget location position gets changed on scrolling.

Animations

MethodsDescription
animate Applies an animation to the widget.
 
PropertiesDescription
transformContains an animation transformation that can be used to animate the widget.
widgetSwipeMoveUsed to enable and configure the left or right swipe actions for a widget.

 

UI Appearance

PropertiesDescription
margin Defines the space around a widget.
opacity Specifies the opacity of the widget.
padding Defines the space between the content of the widget and the widget boundaries.
poster You can specify an image which is to be displayed as a poster or as a starting image for the video.
skin Specifies the look and feel of the video.
widgetAlignment Indicates how a widget is to be anchored with respect to its parent.

 

Enabling RTL

PropertiesDescription
retainContentAlignmentHelps to retain the content alignment of the widget while applying RTL.
retainFlexPositionPropertiesHelps to retain the left, right and padding properties while applying RTL.
retainFlowHorizontalAlignmentEnables you to change the horizontal flow of the widget from left to right.

Miscellaneous

Properties 
cursorTypeSpecifies the type of the mouse pointer used.
source Specifies the URLs of a video that is to be streamed, the path of the video from the local asset, and the video captured from the camera.
text Specifies a general or descriptive text for the Video widget.

 

MethodDescription
getBadge Enables you to read the badge value (if any) attached to the specified widget.
setBadge Enables you to set the badge value to the given widget at the upper, right corner of the widget.

 

EventsDescription
onCompletion Invoked when playback is completed.
onError Invoked when an error occurred in setup or playback.
onPrepared Invoked when the media file is loaded and ready to play.

Configurations Common To All Widgets

PropertiesDescription
accessibilityConfig Enables you to control accessibility behavior and alternative text for the widget.
id id is a unique identifier of a Video consisting of alpha numeric characters.
info A custom JSObject with the key value pairs that a developer can use to store the context with the widget.
isVisible Controls the visibility of the Video widget on the form.
parent Helps you access the parent of the widget.

 

MethodDescription
convertPointFromWidget Allows you to convert the coordinate system from a widget to a point (receiver's coordinate system).
convertPointToWidget Allows you to convert the coordinate system from a point to widget.
removeFromParent Allows you to remove a child widget from a parent widget.
setEnabled Specifies the widget that must be enabled or disabled.
setFocus Specifies the widget on which there must be focus.
setVisibility Set the visibility of the widget.

Video Widget Basics

Creating a Video Using a Constructor: kony.ui.Video


var video = new kony.ui.Video (config);

Example

//Defining the properties for Video with source
var video1 = new kony.ui.Video({
    "id": "video1",
    skin: "vSkin",
    "controls": false,
    "width": "100%",
    "height": "100%",
    "zIndex": 3,
    "source": {
        "mp4": "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4",
        "mov": videofilepath,
        "rawBytes": camera1.rawBytes
    },
    "poster": null,
    "onPrepared": onPreparedCallBack
});

Limitations

iOS

The following are the important considerations for the iOS platform:

SPA

The following are the important considerations for the SPA platform:

Supported devices and video formats for SPA platform.

Category and DeviceOSBrowserVideo Format
(WebM, OGG, MP4, OGV)
XHTML Mandatory Attributes Height/WidthComments
BB Non Touch - BlackBerry 9780 boldBB 6Native BB BrowserMP4SupportedVideo tag doesn't render without XHTML attributes
BB 7.0 (touch) - BlackBerry 9900 Bold and BlackBerry 9860BB 7 Native BB BrowserMP4na 
BB 6.0 (touch) - BlackBerry 9800 TorchBB 6Native BB Browsernot supportedna 
Samsung Galaxy S2 - amsung I9100Android 2.3.3Native Android WebkitMP4na 
Samsung Galaxy S2 - Samsung I9100Android 4.0.4Native Android WebkitMP4na 
Samsung Galaxy S2 - amsung I9100Android 4.0.4Native Android WebkitMP4na 
iPhone - iPhone iOS 4.2.1SafariMP4na 
iPhone - iPhone iOS 6.1.3SafariMP4na 
Windows Phone 8 - Windows Phone 8 (Nokia)OS8IE10MP4na 
premCopyright © 2012 Kony, Inc. All rights reserved.
premCopyright © 2012 Kony, Inc. All rights reserved.