We are closing.

Dm banner

SublimeVideoDocumentation

Application API

load ready prepare unprepare player lightbox version env

See also Using the JavaScript API, Player API and Lightbox API.

sublime.load()

SublimeVideo Player and the sublime API object are automatically loaded upon page load if there is at least one element with sublime class in the DOM. If you have no videos (or lightboxes) initially on the page (and you plan for instance to add them dynamically later with JavaScript) you can use this method to force the loading of the player and the sublime API object.

sublime.ready(callback)

  • callback (Function) – The function to call when the event occurs.

The sublime API object might not be immediately available when the DOM is loaded.

You should avoid making calls to the SublimeVideo JavaScript API in your own DOM loaded/ready method (e.g. DOMContentLoaded, jQuery’s .ready() or Prototype’s dom:loaded) unless you are sure those calls will not be executed immediately, but only upon a future user action (so that, by that time, we’ll be sure the sublime API object has been loaded).

Use sublime.ready to be notified when the sublime API object is actually available or if you want to make calls to our JavaScript API as soon as possible after the page is loaded.

Please note that if you have <video> elements with the sublime class in the DOM, the sublime.ready callback will be called after those elements have been prepared. If you do not add the sublime class to your <video> elements, you have to prepare them manually using the sublime.prepare method that you would call inside the sublime.ready block.

Example

sublime.ready(function(){
  // Code to execute once the SublimeVideo JS API is ready!
});

Important note: All the following methods are to be called once the application is loaded,
preferably inside the sublime.ready block.

sublime.prepare(elementOrId, callback)

  • elementOrId (DOM Element | String) – The DOM element to prepare, or its id. Pass <video> element to prepare players and <a> element to prepare lightboxes.
  • callback (Function) – The function to call once the element is prepared. Depending on the element you are preparing, the callback receives a player or lightbox as parameter.

Sometimes you don’t want SublimeVideo to be setup on page load because you might have some <video> elements hidden in the page that you want to show on demand using JavaScript. In this case, when you initially build your <video> element (in HTML or JavaScript) you don’t have to add the sublime class to it. When you are ready to show the video you then call this method by passing the <video> element (or its id) as an argument.

Example – preparing a player

sublime.prepare('my_video_id', function(player) {
  // player is now ready.
});

Example – preparing a lightbox

sublime.prepare('my_lightbox_trigger_id', function(lightbox) {
  // lightbox is now ready.
});

See also the player API and the lightbox API.

sublime.unprepare(elementOrId)

  • elementOrId (DOM Element | String) – The DOM element to unprepare, or its id.

This method undoes all modifications done by the sublime.prepare method. You basically call it when you want to “unload” a SublimeVideo player or lightbox from the specified DOM element.
A typical scenario where this might be useful is if you have a video on your page and you want another video (which either already exists hidden in the page or a new one loaded from JavaScript) to take up the same area where the initial video was displayed. Before hiding or removing that previous video you need to properly unload SublimeVideo from it by calling the sublime.unprepare method.
Since in most cases you use this method when you’re done with the video and you want to hide (or remove) it from the DOM, the method will actually do it for you: once sublime.unprepare is executed, your <video> element(s) will end up hidden.

sublime.player(elementOrId) ⇒ Object

  • elementOrId (DOM Element | String) – The DOM <video> element or its id.

Returns the player for the given video, or undefined if the video can’t be found in the DOM or the player isn’t prepared.

See the player API for more information.

  • elementOrId (DOM Element | String) – The DOM <a> element or its id.

Returns the lightbox for the given link, or undefined if the link can’t be found in the DOM or the lightbox isn’t prepared.

See the lightbox API for more information.

sublime.version ⇒ String

Returns a string (SemVer compliant) representing the application version.

sublime.env ⇒ String

Returns a string representing the application environment, or undefined if the license is invalid. The possible values are production, staging and development.