public function renderDestroy() { $VideoId = $this->getInt('id'); $Video = new Video($VideoId); $Video->delete(); $msg = new \stdClass(); $msg->type = 'success'; $msg->text = 'Video was successfully deleted'; Redirect::to('/' . $this->baseUri())->with('msg', $msg)->now(); }
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; }
public function renderDestroy() { $categoryId = $this->getInt('id'); $articlesInCategory = Article::collection(['category_id' => $categoryId]); $videosInCategory = Video::collection(['category_id' => $categoryId]); if ($articlesInCategory->hasMappers() || $videosInCategory->hasMappers()) { Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('error', 'Category cannot be deleted. Some Articles/Videos belong to it'))->now(); } else { $category = new Category($categoryId); $category->delete(); Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'Category was successfully deleted'))->now(); } }
/** * Add videos * * @return $this */ protected function _addVideos() { echo 'Adding Videos: '; $count = 0; $captionCount = 0; /** @var Category[] $categories */ $categories = Category::collection(); foreach ($categories as $category) { if (rand(1, 3)) { $videoTitles = $this->_getTitleArray('Video', rand(1, 3)); foreach ($videoTitles as $videoTitle) { $video = new Video(); $video->title = $videoTitle; $video->slug = Strings::urlize($videoTitle); $video->subTitle = $this->_getExampleContent(rand(3, 15)); $video->categoryId = $category->id(); $video->url = 'http://content.bitsontherun.com/videos/lWMJeVvV-364767.mp4'; $video->saveChanges(); // Add Annotations $videoCaptionCount = rand(20, 30); $i = 1; $lastSecond = 0; do { $caption = new VideoCaption(); $caption->videoId = $video->id(); $caption->text = $this->_getExampleContent(rand(2, 6)); $caption->startSecond = $lastSecond; $lastSecond += rand(3, 6); $caption->endSecond = $lastSecond; $caption->saveChanges(); $captionCount++; $i++; } while ($i <= $videoCaptionCount); $count++; } } } echo sprintf('%d (%d Total Captions)%s', $count, $captionCount, PHP_EOL); return $this; }