public function renderVttCaptions($videoId) { $video = new Video($videoId); if (!$video->exists()) { return $this->renderNotFound(); } $webVtt = new WebVTT(); foreach ($video->getCaptions() as $caption) { $webVtt->addCaption($caption->startSecond, $caption->endSecond, $caption->text); } echo $webVtt->render(); exit; }