var callback = arguments[arguments.length - 1];
function check_playback() {
  var permissibleVariation = 0.25;
  while ( parseInt(Date.now() / 1000) < endTime ) {
    console.clear();
    currTime = player.getCurrentTime();
    expectedTime = currTime + 2;
    setTimeout(function(){
      nextTime = player.getCurrentTime();
      if ((expectedTime + permissibleVariation) > nextTime > (expectedTime - permissibleVariation)) {
        callback({
          'success': false,
          'message': 'Expected Playhead within ' + expectedTime + ' with variation ' + permissibleVariation + '. Got Playhead - ' + nextTime
        });
      }
    }, 2000);
  }
  callback({'success': true, 'message': ''});
}
var currTime = 0;
var expectedTime = 0;
var startTime = parseInt(Date.now() / 1000);
var endTime = (startTime + #{duration});
check_playback();
