Documentation
v0.4.0
iOSAndroidJavaScript

Services

V.account
Expand all / Collapse all

This service allows you control account session.

Properties

appIdString
Current application identifier
sessionTokenString
Authorization session token
secretTokenString
Secret application token (should be used only for testing purposes)

Methods

init()init(params)
Initialize SDK account with passed params. This method can be called multiple time during runtime if you want to change used application.
Arguments
params

Object *required

Init params
params.appId

String *required

Application id
params.sessionToken

String

Authorization session token
params.secretToken

String

Secret application token (should be used only for testing purposes)
Return
Promose - Promise object.
updateToken()updateToken(params)
Update authorization token
Arguments
params

Object *required

Token object
params.sessionToken

String

Authorization session token
params.secretToken

String

Secret application token (should be used only for testing purposes)
deleteToken()deleteToken()
Delete authorization token
subscribe()subscribe(event, callback)
Subscribe on event
Arguments
event

String *required

This string can contain: event name, namespace of event name, list of event names separated by a space or '*' to subscribe on all events
callback

Function *required

Callback function
unsubscribe()unsubscribe(event, callback)
Unsubscribe from event
Arguments
event

String *required

This string can contain: event name, namespace of event name, list of event names separated by a space or '*' to unsubscribe from all events
callback

Function *required

Callback function

Events

init
Triggered when account has been initialized
token.delete
Triggered when token has been deleted
token.expire
Triggered when token has expired
token.update
Triggered when token has been updated

V.videos
Expand all / Collapse all

This service allows you to manage videos.

Methods

get()get(ids, [callback])
Return list of videos
Arguments
ids

String | Object *required

Video id or list of video ids
callback

Function

Callback function
Return
Promise - Promise object
Example
Copy
V.videos.get('548f048c-6170-691f-a206-3e0000000000').then(function(videos) {});

V.videos.get([
   '548f048c-6170-691f-a206-3e0000000000',
   '548f048c-6170-691f-a2fd-3d0000000000'
]).then(function(videos) {});
create()create(video, [callback])
Create new video
Arguments
video

Object *required

Video params
video.title

String

Video title
video.description

String

Video description
video.metadata

Object

Object with metadata
video.tags

Array

List of tags
callback

Function

Callback function
Return
Promise - Promise object
Example
Copy
 V.videos.create({
     title: 'My new video',
     tags: ['cats']
 }).then(function(video) {});
update()update(video, [callback])
Update specified video
Arguments
video

Object *required

Video params
video.id

String *required

Video id
video.title

String

Video title
video.description

String

Video description
video.metadata

Object

Object with metadata
video.tags

Array

List of tags
callback

Function

Callback function
Return
Promise - Promise object
Example
Copy
 V.videos.update({
     id: '523b2185-874c-4c7f-9a41-ad651737f047',
     title: 'New video title',
     tags: ['dogs']
 }).then(function(video) {});
remove()remove(id, [callback])
Delete specified video
Arguments
id

String *required

Video id
callback

Function

Callback function
Return
Promise - Promise object
Example
Copy
 V.videos.remove('523b2185-874c-4c7f-9a41-ad651737f047').then(function(response) {});
convert()convert(id, filename, [callback])
Start convert process for specified video file to all other formats
Arguments
id

String *required

Video id
filename

String *required

Filename of video file from storage, that should be used for convertion
callback

Function

Callback function
Return
Promise - Promise object
Example
Copy
 V.videos.convert('523b2185-874c-4c7f-9a41-ad651737f047', 'video_000000.mp4').then(function(response) {});
getStorage()getStorage(id, fileType, [callback])
Return data for uploading of video to storage
Arguments
id

String *required

Video id
fileType

String *required

Mime type of uploading file ('video/mp4', 'video/mpeg', 'video/quicktime', 'video/avi')
callback

Function

Callback function
Return
Promise - Promise object
Example
Copy
 V.videos.getStorage('523b2185-874c-4c7f-9a41-ad651737f047', 'video/mp4').then(function(storage) {});
subscribeOnNewVideos()subscribeOnNewVideos([params], handler)
Create subscription on new videos with passed params
Arguments
params

Object

Video params, should contain at least one of params
params.tags

Array

Tags of new video
params.metadata

Object

Metadata of new video
handler

Function *required

Handler function, will be called with video object of new video
Return
Function - Unsubscribe function, calling of this function will remove current subscription on new videos
Example
Copy
 V.videos.subscribeOnNewVideos({
     metadata: {
         item_id: '4929382374812'
     }
 }, function(video) {});

 V.videos.subscribeOnNewVideos({
     tags: ['cats']
 }, function(video) {});
subscribe()subscribe(event, callback)
Subscribe on event
Arguments
event

String *required

This string can contain: event name, namespace of event name, list of event names separated by a space or '*' to subscribe on all events
callback

Function *required

Callback function
Example
Copy
V.videos.subscribe(event, callback);
unsubscribe()unsubscribe(event, callback)
Unsubscribe from event
Arguments
event

String *required

This string can contain: event name, namespace of event name, list of event names separated by a space or '*' to unsubscribe from all events
callback

Function *required

Callback function
Example
Copy
V.videos.unsubscribe(event, callback);

Events

create
Triggered when video has been created in the current application
Data
Object - Created video data

{
  id: 'CREATED_VIDEO_ID'
}
delete
Triggered when video from the current application has been deleted
Data
Object - Deleted video data

{
  id: 'DELETED_VIDEO_ID'
}
update
Triggered when video from the current application has been updated
Data
Object - Updated video data

{
  id: 'UPDATED_VIDEO_ID',
  changes: {
    'CHANGED_VIDEO_PROPERTY': 'NEW_VALUE'
  }
}

Methods

V.ui()V.ui(componentName, parentContainer, parameters)
Create UI component
Arguments
componentName

String *required

Name of UI component
parentContainer

HTMLElement *required

Element that will contain UI component
parameters

Object *required

Parameters of UI component
V.ui.init()V.ui.init([container])
Initialize new ui components found in specified html container.
Arguments
container

HTMLElement

Container where need to initialize new ui components (By default uses entire document)
Example
Copy
 V.ui.init(document.body);
V.ui.getInstance()V.ui.getInstance(element)
Return instance of ui component
Arguments
element

Number | String | HTMLElement *required

Root element or id of ui component
Return
Object - Instance of ui component
Example
Copy
 V.ui.getInstance(document.querySelector('.v-player'));

UI Components

Player
Expand all / Collapse all

This component creates instance of single video player. Player supports following modules:

  • progress - create playback control
  • rate - create rate control
  • volume - create volume control
  • fullscreen - create fullscreen control, that allows you to toggle browser fullscreen mode
  • videoInfo - create block with information about current video (date, owner and location)

Parameters

video

String | Object *required

Video object or video id
modules

Array (By default: all)

List of modules that should be included in player instance
loop

Boolean (By default: false)

Whether player should loop playing of video
autoPlay

Boolean (By default: false)

Whether player should start playing of video as soon as it is loaded
playOnFocus

Boolean (By default: false)

Whether player should start playing of video when video is in the middle of the screen
volume

Number (By default: 50)

Player init volume
rate

Number (By default: 1)

Player playback rate
size

String | Object | Function

By default, player inherits width of container element and height will be calculated in accordance with video ratio. To customize player sizes available 3 options:
  • 'parent', in this case width and height will be inherited from parent container element
  • object with width and height parameters (values should be in pixels)
  • function that returns object with width and height. Function will be called with current video object as the first argument
aspectMode

String (By default: resizeAspectFill)

Parameter that define players aspect mode, available 3 options:
  • 'resizeAspect', the aspect ratio of video is respected and the entire video frame could be seen.
  • 'resizeAspectFill', the aspect ratio of video is respected but the video frame would fill the entire player block.
  • 'resize', the aspect ratio of video is not respected but the entire video frame would fill the player block.
template

String

Custom template for ui component
templateData

Function

Function that return data for custom template

Example

 V.ui('player', parentContainer, {
     video: VIDEO_OBJECT,
     modules: ['progress', 'rate', 'volume', 'fullscreen', 'videoInfo'],
     loop: true,
     autoPlay: true,
     volume: 100
 });

Methods

load()load()
Start preloading of current video
unload()unload()
Unload current video
play()play([params])
Start playback of current video
Arguments
params

Object

Playback params (e.g. currentTime)
pause()pause()
Pause playback of current video
getVideo()getVideo()
Return current video
Return
Object - Video object of the current video
setVideo()setVideo(video)
Set new video to player
Arguments
video

String | Object *required

Video object or video id
getVolume()getVolume()
Return current volume value
Return
Number - Current volume value
setVolume()setVolume(volume)
Set new volume value
Arguments
volume

Number *required

Volume value (from 0 to 1)
getCurrentTime()getCurrentTime()
Return current time of playback
Return
Number - Current time of playback in seconds
setCurrentTime()setCurrentTime(currentTime)
Set current time of playback
Arguments
currentTime

Number *required

Current time of playback
getPlaybackRate()getPlaybackRate()
Return current playback rate
Return
Number - Playback rate
setPlaybackRate()setPlaybackRate(rate)
Set current playback rate
Arguments
rate

Number *required

Playback rate
getLoop()getLoop()
Return player loop param
Return
Boolean - Value of loop flag
setLoop()setLoop(loop)
Set player loop param
Arguments
loop

Boolean *required

Whether player should loop playing of video
getAspectMode()getAspectMode()
Return player aspect mode
Return
String - Aspect mode value (resizeAspect, resizeAspectFill, resize)
setAspectMode()setAspectMode(aspectMode)
Set player aspect mode
Arguments
aspectMode

String *required

Aspect mode value (resizeAspect, resizeAspectFill, resize)
getState()getState()
Return state of player (paused/playing)
Return
String - State of player
isLoaded()isLoaded()
Return flag whether the current video is loaded
Return
Boolean - Boolean flag
isFullScreen()isFullScreen()
Return flag whether player is in the fullscreen mode
Return
Boolean - Boolean flag
toggleFullScreen()toggleFullScreen()
Toggle fullscreen mode (should be called only in callback of user event)
updateSize()updateSize()
Update sizes of player
subscribe()subscribe(event, callback)
Subscribe on component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
unsubscribe()unsubscribe(event, callback)
Unsubscribe from component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
destroy()destroy()
Destroy component instance and remove from the DOM

Events

ended
Triggered when playback of video is ended
enterfullscreen
Triggered when player entered to fullscreen mode
error
Triggered when some error occurred
exitfullscreen
Triggered when player exited from fullscreen mode
loaded
Triggered when current video has been fully loaded
pause
Triggered when video has been paused
play
Triggered when video has been started or is no longer paused
playing
Triggered when video is playing after having been paused or stopped for buffering
progress
Triggered when progress of downloading of current video has been changed
Data
Number - Progress of video downloading (from 0 to 1)
rateupdate
Triggered when player rate has been changed
Data
Number - Current (from 0 to 2)
timeupdate
Triggered when time of playback has been updated
Data
Number - Current time in seconds
volumeupdate
Triggered when player volume has been changed
Data
Number - Current volume (from 0 to 100)

Playlist
Expand all / Collapse all

This component allows you to playback list of videos with smart preloading. Component has 2 types: standard and feed. Standard type of playlist looks like single player with 2 arrows to navigate in list of videos. Feed type of playlist looks like list of single players and plays videos during scrolling of the page.

In case if you need to play videos with particular tags or metadata, ordered by date of creation, you can pass these params to `fetchParams` parameter or resetFetchParams method and component will fetch all videos from the server. If you have some specific video sequence, you should get videos by your own and pass them to `videos` parameter or resetVideos method.

Playlist component has the same modules as player:

  • progress - create playback control
  • rate - create rate control
  • volume - create volume control
  • fullscreen - create fullscreen control, that allows you to toggle browser fullscreen mode
  • videoInfo - create block with information about current video (date, owner and location)

Parameters

type

String (By default: standard)

Type of playlist component (standard or feed)
videos

Array

List of videos to play
fetchParams

Object

Params for getting of videos from server
fetchParams.tags

Array

List of tags, that will be used for getting of videos
fetchParams.metadata

Object

Object with metadata, that will be used for getting of videos
fetchParams.sortOrder

String (By default: asc)

Sort order of videos in playlist
fetchParams.perPage

Number (By default: 50)

Number of videos, that will be loaded in each server request
startPoint

String (By default: beginning)

Start point of playback in video sequence (beginning, end or id of particular video)
player

Object (By default: {})

Player parameters
player.loop

Boolean (By default: false)

Whether player should loop playing of video
player.autoPlay

Boolean (By default: true)

Whether player should start playing of video as soon as it is loaded. In case of feed type of playlist, component will scroll page to the start video after initialization.
player.volume

Number (By default: 50)

Player init volume
player.rate

Number (By default: 1)

Player init playback rate
player.size

String | Object | Function

By default, player inherits width of container element and height will be calculated in accordance with video ratio. To customize player sizes available 3 options:
  • 'parent', in this case width and height will be inherited from parent container element
  • object with width and height parameters (values should be in pixels)
  • function that returns object with width and height. Function will be called with current video object as the first argument
This parameter applies only for feed type playlist, for standard playlist it always inherits parent container sizes
player.aspectMode

String (By default: resizeAspectFill)

Parameter that define players aspect mode, available 3 options:
  • 'resizeAspect', the aspect ratio of video is respected and the entire video frame could be seen.
  • 'resizeAspectFill', the aspect ratio of video is respected but the video frame would fill the entire player block.
  • 'resize', the aspect ratio of video is not respected but the entire video frame would fill the player block.
player.template

String

Custom template for player component
player.templateData

Function

Function that return data for custom template

Example

 V.ui('playlist', parentContainer, {
     type: 'standard',
     fetchParams: {
         metadata: {
             KEY: 'VALUE'
         },
         tags: ['TAG'],
         sortOrder: 'desc',
         perPage: 20
     },
     startPoint: 'VIDEO_ID',
     modules: ['progress', 'rate', 'volume', 'fullscreen', 'videoInfo']
 });

 V.ui('playlist', parentContainer, {
     type: 'feed',
     videos: [VIDEO_OBJECT, VIDEO_OBJECT, ...],
     modules: ['progress', 'rate', 'volume', 'fullscreen', 'videoInfo']
 });

Methods

addVideos()addVideos(videos, [position])
Add videos to the current playlist
Arguments
videos

Object | Array *required

Video object or array of video objects, that should be added to playlist
position

Number

Position of the adding videos in playlist
resetVideos()resetVideos(videos)
Reset current playlist with passed videos
Arguments
videos

Array *required

Array of video objects
getVideos()getVideos()
Get videos of current playlist
Return
Array - Array of video objects
fetchPreviousVideos()fetchPreviousVideos()
Fetch previous videos before current video
fetchNextVideos()fetchNextVideos()
Fetch next videos after current video
resetFetchParams()resetFetchParams(fetchParams)
Reset current fetch params with specified
Arguments
fetchParams

Object *required

Fetch params (tags, metadata, sortOrder, perPage)
getFetchParams()getFetchParams()
Return current fetch params
Return
Object - Fetch params
getCurrentVideo()getCurrentVideo()
Return current video
Return
Object - Current video
setCurrentVideo()setCurrentVideo(id)
Change current video to specified
Arguments
id

String *required

Video id
previousVideo()previousVideo()
Go to the previous video in the playlist
nextVideo()nextVideo()
Go to the next video in the playlist
play()play(params)
Start playback of current video
Arguments
params

Object *required

Playback params (e.g. currentTime)
pause()pause()
Pause playback of current video
getVolume()getVolume()
Return current volume value
Return
Number - Current volume value
setVolume()setVolume()
Set new volume value
getCurrentTime()getCurrentTime()
Return current time of playback
Return
Number - Current time of playback in seconds
setCurrentTime()setCurrentTime(currentTime)
Set current time of playback
Arguments
currentTime

Number *required

Current time of playback
getPlaybackRate()getPlaybackRate()
Return current playback rate
Return
Number - Playback rate
setPlaybackRate()setPlaybackRate()
Set current playback rate
getAspectMode()getAspectMode()
Return player aspect mode
Return
String - Aspect mode value (resizeAspect, resizeAspectFill, resize)
setAspectMode()setAspectMode(-)
Set player aspect mode
Arguments
-

String *required

Aspect mode value (resizeAspect, resizeAspectFill, resize)
getState()getState()
Return state of player (paused/playing)
Return
String - State of player
isLoaded()isLoaded()
Return flag whether the current video is loaded
Return
Boolean - Boolean flag
isFullScreen()isFullScreen()
Return flag whether player is in the fullscreen mode
Return
Boolean - Boolean flag
updateSize()updateSize()
Update sizes of player
toggleFullScreen()toggleFullScreen()
Toggle fullscreen mode (should be called only in callback of user event)
subscribe()subscribe(event, callback)
Subscribe on component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
unsubscribe()unsubscribe(event, callback)
Unsubscribe from component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
destroy()destroy()
Destroy component instance and remove from the DOM

Events

playlist.change
Triggered when playlist has been changed
Data
Array - Updated playlist
playlist.empty
Triggered when there are no videos with specified fetch parameters
playlist.enterfullscreen
Triggered when playlist entered to fullscreen mode
playlist.exitfullscreen
Triggered when playlist exited from fullscreen mode
video.*
Playlist component has all events that has player component, but their names start from 'video' namespace. E.g.: 'video.playing', 'video.loaded', 'video.volumeupdate', etc.
video.change
Triggered when current video has been changed
Data
Object - Object of current video

Upload
Expand all / Collapse all

This component allows you to upload new videos. Workflow of component contains several steps: first of all, when user selected file to upload, component creates new video entity. After that starts uploading of video file to the storage. Then starts processing of the uploaded file and after that you can watch new video.

Parameters

tags

Array

List of tags, that will be added to new video
metadata

Object

Metadata, that will be added to new video

Example

 V.ui('upload', parentContainer, {
     tags: ['TAG']
 });

 V.ui('upload', parentContainer, {
     metadata: {
         KEY: 'VALUE'
     }
 });

Methods

updateParams()updateParams(params)
Update component parameters
Arguments
params

Object *required

Component parameters
videoData.tags

Array

List of tags, that will be added to new video
videoData.metadata

Object

Metadata, that will be added to new video
getState()getState()
Return current state of upload component
Return
String - Current state (inactive, upload, processing, done)
setState()setState([state])
Set state of upload component
Arguments
state

String (By default: inactive)

State of upload component (inactive, upload, processing, done)
getProgress()getProgress()
Return value of upload progress
Return
Number - Value of upload progress (from 0 to 100)
getVideo()getVideo()
Return video object of uploaded video
Return
Object | Null - Video object or null if video has not been created
subscribe()subscribe(event, callback)
Subscribe on component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
unsubscribe()unsubscribe(event, callback)
Unsubscribe from component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
destroy()destroy()
Destroy component instance and remove from the DOM

Events

processing.ended
Triggered when processing of uploaded video has been ended
processing.start
Triggered when processing has been started
upload.ended
Triggered when upload has been ended
upload.error
Triggered when occurs error during of upload
Data
String - Error message
upload.progress
Triggered when progress of uploading has been changed
Data
Number - Progress of uploading (from 0 to 100)
upload.start
Triggered when uploading has been started
video.create
Triggered when new video has been created
Data
Object - Video object
watch
Triggered when watch link has been clicked
Data
Object - Video object

QR code
Expand all / Collapse all

Since JS SDK has not supported recording of videos yet, you can use this component to pass recording functionality to mobile application. This component generates QR code with encoded video data, that you want to use for recording of video. Then you can scan this code by your mobile device with help of mobile SDK. Mobile SDK will recognize video data and will launch recorder, that will record video using this data.

Parameters

title

String

QR code title, this title will be shown in mobile SDK after QR code recognition
tags

Array

List of tags for new video
metadata

Object

Metadata for new video
size

Number (By default: 200)

Size of component in pixels

Example

 V.ui('qrcode', parentContainer, {
     title: 'QR title',
     tags: ['TAG'],
     metadata: {
         KEY: 'VALUE'
     },
     size: 200
 });

Methods

updateParams()updateParams(params, [title])
Update component parameters and rebuild QR code
Arguments
params

Object *required

Component parameters
title

String

QR code title, this title will be shown in mobile SDK after QR code recognition
params.tags

Array

List of tags for new video
params.metadata

Object

Metadata for new video
params.size

Number

Size of component in pixels
subscribe()subscribe(event, callback)
Subscribe on component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
unsubscribe()unsubscribe(event, callback)
Unsubscribe from component event
Arguments
event

String *required

Event name
callback

Function *required

Callback function
destroy()destroy()
Destroy component instance and remove from the DOM