Integration API Documents > HTML 5 API

Integration API Documents

HTML 5 API

The HTML 5 API ia a JavaScript solution to overlay content created by SubPLY


This API is a JSONP based integration where the content is a JSON static file.

SubPLY will automatically publish this JSON file for HTML 5 integrated customers.

JSONP Example:

var dynamicScriptTag = document.createElement('script');
var source = "http://subply.plymedia.com.s3.amazonaws.com/scripts/Html5_" + language + ".js";
dynamicScriptTag.type = 'text/javascript';
dynamicScriptTag.src = source;
dynamicScriptTag.setAttribute("id", "subPLYScript");
document.getElementsByTagName('body')[0].appendChild(dynamicScriptTag);

To generate a static JSON file please use the Transcript API with "html5" as the requested format:

Example:

http://api.subply.com/content/html5/eng?url=http%3a%2f%2fwww.youtube.com%2fwatch%3fv%3dhrixBl5PgNg

Result:

A Text result in the requested format. Following is the result from the above example:

var captionData = [{"TotalRows":13,"rows":[{"start":49.89,"end":58.6,"text":"I heard he sang a good song\nI heard he had a style"},{"start":59.739999999999995,"end":68.55,"text":"And so I came to see him\nand listen for a while"},{"start":68.83,"end":78.71,"text":"And there he was, this young boy\na stranger to my eyes"},{"start":79.149999999999991,"end":88.88,"text":"Strumming my pain with his fingers\nSinging my life with his words"},{"start":89.55,"end":97.81,"text":"Killing me softly with his song\nKilling me softly.. with his song"},{"start":98.429999999999993,"end":103.08999999999999,"text":"Telling my whole life\n with his words"},{"start":103.5,"end":113.83,"text":"Killing me softly... \nwith his song"},{"start":115.88,"end":125.33999999999999,"text":"I felt all flushed with fever\nembarrassed by the crowd"},{"start":125.78,"end":134.85,"text":"I felt he found my letters\nand read each one out loud"},{"start":135.63,"end":144.94,"text":"I prayed that he would finish\nbut he just kept right on, yeah.."},{"start":145.66,"end":155.26,"text":"Strumming my pain with his fingers\nYes, he was singing my life with his words, yeah"},{"start":155.95,"end":164.32,"text":"Killing me softly with his song\nKilling me softly.. with his song"},{"start":164.73,"end":179.36999999999998,"text":"Telling my whole life with his words\nKilling me softly... with his song"}]}];

function syncCaptions(currentTime, divObject) {
try {
  for (var i = 0; i < captionData.length; i++) {
   var line = captionData[i];
   if (currentTime >= line.From && currentTime <= (line.From + line.Duration)) {
    document.getElementById(divObject).innerHTML=line.Text;
    break;
   }
  }
}
  catch (err) { }
}