Custom render method

You can set a custom render method to have full control over the rendering of the subtitles.

<iframe id="video" width="100%" height="400" src="https://www.youtube.com/embed/fGPPfZIvtCw" frameborder="0" allowfullscreen="true"></iframe>
<script src="static/vendor/youtube.external.subtitle/youtube.external.subtitle.js"></script>
<script src="static/vendor/subtitles-parser/subtitles.parser.js"></script>
<script>
  var loadSRT = function(url, callback) {
    var httpRequest = new XMLHttpRequest();

    httpRequest.onreadystatechange = function() {
      if (httpRequest.readyState === XMLHttpRequest.DONE) {
        var subtitles = parser.fromSrt(httpRequest.responseText, true);

        for (var i in subtitles) {
          subtitles[i] = {
            start : subtitles[i].startTime / 1000,
            end   : subtitles[i].endTime / 1000,
            text  : subtitles[i].text
          };
        }

        callback(subtitles);
      }
    };

    httpRequest.open('GET', url, true);
    httpRequest.send(null);
  };

  var customRenderMethod = function(subtitleRootElement, player, isFullscreenActive, text, controlsVisible) {
    subtitleRootElement.innerHTML = '<span>' + (text === null ? '' : text).replace(/(?:\r\n|\r|\n)/g, '</span><br /><span>') + '</span>';
    subtitleRootElement.style.padding = '10px';
    subtitleRootElement.style.background = 'red';
    subtitleRootElement.style.color = 'white';
    subtitleRootElement.style.fontSize = '18px';
  };

  loadSRT('static/srt/kung_fu_panda_3_trailer.srt', function(subtitles) {
    var youtubeExternalSubtitle = new YoutubeExternalSubtitle.Subtitle(document.getElementById('video'), subtitles, customRenderMethod);
  });
</script>