Widgets API - GoREACT/widgets-js-api GitHub Wiki

The documentation provides the currently available public API.

##Authorization

####goreact.authorize( settings : Object, signature: String ) : void

Used to authorize GoReact and validate user. This function must be called and completed before any other API calls are made.

####Required params

api_key : String

Key used to interface with GoReact's JavaScript API.

user_id : Number or String

The ID of the current authenticated user.

first_name : String

The first name of the current authenticated user.

last_name : String

The last name of the current authenticated user.

email : String

The email address of the current authenticated user.

context_id : String

The id of the context which represents the scope of a given set of videos

context_name : String

The name of the context which represents the scope of a given set of videos

context_role : Enum ("instructor", "reviewer", "presenter")

The role of the context

####Optional params

expires : UTC timestamp

It will expire the signature at the given time. If not provided, signature will not expire?

####Events

The following events are dispatched when goreact.authorize() is called.

authorize::success

Invoked when the authorization was successful.

authorize::error

Invoked when the authorization has failed.

####Example

var signature = "5eb63bbbe01eeed093cb22bb8f5acdc3";
goreact.authorize({
    api_key: "9plmvlph",
    user_id: "5432b03462ccc7ea7bcc2c41",
    context_id: "5432b0923ea55a487d96b076",
    context_name: "Business Ed",
    context_role: "instructor",
    name: "John Smith",
    email: "[email protected]",
    expires: 1413496405
}, signature);

goreact.on('authorize::success', function(evt, widget) {...});

goreact.on('authorize::error', function(evt, widget) {...});

###goreact.record( options : Object ) : void

Loads a recording widget.

require_title : Boolean

Optional. Whether a title is required before the recording is posted. Default is true.

persist : Object

Optional. Transient data which will persist until the final callback occurs.

container : <body> / DOM / Style

Optional. The container indicates where to load the widget. There are three options available:

  1. Default: <body> tag.
  2. DOM element: serves as a container. The element controls the dimensions of the widget. Having the size defined either through width / height or absolute positioning is recommended.
  3. Style: Object that sets the style of the container created by GoREACT. This container acts like the default with the exception that you can set the dimensions, or any other property on the container.

####Events

The following events are dispatched when goreact.record() is called.

record::start

Invoked when the user has started the recording.

record::started

Invoked when the recording has started.

record::stop

Invoked when the user has stopped the recording.

record::stopped

Invoked when the recording has stopped.

record::post

Invoked when the user has saved the recording.

record::postSuccess

Invoked when the recording is successfully saved.

record::postError

Invoked when the recording failed to save.

record::discard

Invoked when the user has discarded the recording.

record::discardSuccess

Invoked when the recording is successfully discarded.

record::discardError

Invoked when the recording failed to be discarded.

####Example

goreact.record({
     container: element
});

goreact.on('record::start', function(evt, widget, data) {...});

goreact.on('record::stop', function(evt, widget, data) {...});

###goreact.upload( options : Object ) : void

Loads an upload widget.

require_title : Boolean

Optional. Whether a title is required before the upload is posted. Default is true.

persist : Object

Optional. Transient data which will persist until the final callback occurs.

container : <body> / DOM / Style

Optional. The container indicates where to load the widget. There are three options available:

  1. Default: <body> tag.
  2. DOM element: serves as a container. The element controls the dimensions of the widget. Having the size defined either through width / height or absolute positioning is recommended.
  3. Style: Object that sets the style of the container created by GoREACT. This container acts like the default with the exception that you can set the dimensions, or any other property on the container.

####Events

The following events are dispatched when goreact.upload() is called.

upload::fileAdded

Invoked when a file has been added to the upload queue.

upload::start

Invoked when a file upload starts.

upload::stop

Invoked when a file upload has stopped.

upload::active

Invoked when the uploader becomes active or inactive, i.e. a file is being uploaded.

upload::userAborted

Invoked when the user intentionally cancels the upload.

upload::success

Invoked when a file successfully uploads.

upload::failed

Invoked when a file fails to upload.

upload::post

Invoked when the user has saved the uploaded media.

upload::postSuccess

Invoked when the uploaded media is successfully saved.

upload::postError

Invoked when the uploaded media failed to save.

####Example

goreact.upload({
     container: element
});

goreact.on('upload::fileAdded', function(evt, widget, file) {...});

goreact.on('upload::start', function(evt, widget) {...});

goreact.on('upload::stop', function(evt, widget) {...});

###goreact.list( options : Object ) : void

Loads a widget listing recorded videos.

container : <body> / DOM / Style

Optional. The container indicates where to load the widget. There are three options available:

  1. Default: <body> tag.
  2. DOM element: serves as a container. The element controls the dimensions of the widget. Having the size defined either through width / height or absolute positioning is recommended.
  3. Style: Object that sets the style of the container created by GoREACT. This container acts like the default with the exception that you can set the dimensions, or any other property on the container.

####Example

goreact.list({
     container: element
});

###goreact.playback( options : Object ) : void

Loads a playback widget to play a particular session.

goreact_id : String

This ID is used to load the media and its dependencies in the recording widget.

container : <body> / DOM / Style

Optional. The container indicates where to load the widget. There are three options available:

  1. Default: <body> tag.
  2. DOM element: serves as a container. The element controls the dimensions of the widget. Having the size defined either through width / height or absolute positioning is recommended.
  3. Style: Object that sets the style of the container created by GoREACT. This container acts like the default with the exception that you can set the dimensions, or any other property on the container.

####Events

The following events are dispatched when goreact.playback() is called.

playback::play

Invoked when playback has started.

playback::pause

Invoked when playback has paused.

playback::seek

Invoked when playback seeks.

playback::buffer

Invoked when playback is buffering.

playback::playError

Invoked when an error occurs before or during playback.

####Example

goreact.playback({
     goreact_id: 1234,
     container: element
});
goreact.on('playback::play', function(evt, widget, data) {...});

goreact.on('playback::pause', function(evt, widget, data) {...});

goreact.on('playback::seek', function(evt, widget, data) {...});

goreact.on('playback::buffer', function(evt, widget, data) {...});

###goreact.collaborate( options : Object ) : void

Loads a widget to invoke reviewing and feedback of a video.

goreact_id : String

This ID is used to load the media and its dependencies.

use_as_template : Boolean

When true, the goreact_id represents a collaboration session template from which a new collaboration session will be created. Default is false.

persist : Object

Optional. Transient data which will persist until the final callback occurs.

container : <body> / DOM / Style

Optional. The container indicates where to load the widget. There are three options available:

  1. Default: <body> tag.
  2. DOM element: serves as a container. The element controls the dimensions of the widget. Having the size defined either through width / height or absolute positioning is recommended.
  3. Style: Object that sets the style of the container created by GoREACT. This container acts like the default with the exception that you can set the dimensions, or any other property on the container.

media_url : String

Optional. A URL for a publicly-available media file. Also include media_title, media_duration, media_size and media_thumbnail. Should not be used when specifying a goreact_id.

media_title : String

Optional. A title for the external media file. Should not be used when specifying a goreact_id.

media_duration : Number

Optional. The duration of the external media file in milliseconds. Should not be used when specifying a goreact_id.

media_size : Number

Optional. The size of the external media file in bytes. Should not be used when specifying a goreact_id.

media_thumbnail : String

Optional. A URL for a thumbnail image of the external media file. Should not be used when specifying a goreact_id.

####Example

goreact.collaborate({
     goreact_id: 1234,
     container: element
});

####External File Example

goreact.collaborate({
     media_url: “url”,
     media_title: “your title”,
     media_duration: milliseconds,
     media_size: bytes,
     media_thumbnail_url: “url”,
     containter: element
});

###goreact.destroy( widgetId : String ) : void

Destroy a widget by its ID.

###goreact.on( event : String , handler : Function ) : void

Subscribes to events dispatched by the widgets.

Widgets can dispatch the following events:

[widget]:ready

Dispatched when widget is initialized and ready.

Example

goreact.on('record::ready', function(evt, widget){
	console.log(evt, widget.id, widget.url)
});

[widget]:error

Dispatched when an error occurs before the widget is ready.

Example

goreact.on('record::error', function(evt, widget, data){
	console.log(evt, widget.id, widget.url, data)
});

[widget]:destroyed

Dispatched when widget has been removed from the DOM.

Example

goreact.on('record::destroyed', function(evt, widget){
	console.log(evt, widget.id, widget.url)
});