Caption track in Kentico banner video

L Younkins asked on July 9, 2021 17:07

I have a video playing as a banner that uses javascript. I need to add a caption track, but just adding the caption code to the video section doesn't work. I am not sure if this is a JS issue or Kentico issue. Below is my code:

<video id="BannerVideo3" class="Banner" muted playsinline loop oncanplaythrough="playBannerVideo3()" controls autoplay muted playsinline>
</video>

<script>
function playBannerVideo3()
{
  var videoElement = document.getElementById('BannerVideo3');
  try 
  {
    videoElement.play();
  }
  catch(err) {}
}

var basePosterURL = '/FCC/media/Images/Home2018/Banner/BannerVideo3.jpg';
var baseVideoURL = '/FCC/media/Images/Home2018/Banner/BannerVideo3.mp4';

function getNameForCurrentWidth()
{
  var bodyWidth = document.body.clientWidth; // $('body').width();
  if (bodyWidth <= 767)
    return '_Phone';

  if (bodyWidth <= 990)
    return '_Tablet';

  return ''; // Desktop
}

var loadedWidthName;
function loadBannerVideo3(posterOnly)
{
  var newWidthName = getNameForCurrentWidth();
  if(newWidthName == loadedWidthName)
    return;

  loadedWidthName = newWidthName;
  var videoElement = document.getElementById('BannerVideo3');

  if (!videoElement.paused)
    videoElement.pause();

  videoElement.src = '';
  videoElement.poster = addToFilename(basePosterURL, loadedWidthName);

  if (posterOnly == true)
    return;

  setBannerVideoSrc(loadedWidthName);
}

function setBannerVideo3Src(newWidthName)
{
  // don't play video if in design or edit modes
  if( $('body.DesignMode').length == 1 ||  $('body.EditMode').length == 1)
    return;

  var videoElement = document.getElementById('BannerVideo3');
  videoElement.src = addToFilename(baseVideoURL, newWidthName);
  videoElement.load();
}

// load poster as soon as possible
$(function() // document.ready
{
  loadBannerVideo3(true);
});

  // load and play video after everything else loads
$(window).on('load',function()
{
  setBannerVideo3Src(loadedWidthName);
});

var resizeTimeout;
$(window).resize(function()
{ 
  clearTimeout(resizeTimeout);
  resizeTimeout = setTimeout(resizeEnd, 200);   
});
function resizeEnd()
{
  loadBannerVideo();
}
</script>

   Please, sign in to be able to submit a new answer.