// Since the admin interface doesn't offer options for setting controls or sound, we will set some defaults here
$attributes['controls'] = '1';
$attributes['sound'] = '1';
-
$attributes['setup'] = static::getVideoSetup($data, $compiler);
return $attributes;
public static function getVideoSetup($data, $compiler)
{
-
static::addVideoJS($compiler); // Ensure videoJS core is included first
switch ($data->video_service) {
public function getHTMLContent()
{
-
if ($this->video_service !== 0) {
- return $this->getEmbed();
+ return self::getEmbed($this);
}
$w = round($this->width * $this->getCssScale());
$h = round($this->height * $this->getCssScale());
- return $this->makeVideoTag($this, $w, $h, $this->compiler);
+ return self::makeVideoTag($this, $w, $h, $this->compiler);
}
- public function getEmbed()
+ public static function getEmbed($link, $width = null, $height = null)
{
- return '<iframe width="' . $this->width . '" height="' . $this->height . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
+ if (null === $width) {
+ $width = $link->width;
+ }
+ if (null === $height) {
+ $height = $link->height;
+ }
+ return '<iframe width="' . $width . '" height="' . $height . '" src="' . self::getEmbedURL($link) . '" frameborder="0" allowfullscreen></iframe>';
}
- public function getEmbedURL()
+ public static function getEmbedURL($data)
{
- if ($this->video_service == 0) {
- $url = 'https://www.youtube.com/embed/' . $this->to . '?html5=1';
- } elseif ($this->video_service == 1) {
- $url = 'https://www.dailymotion.com/embed/video/' . $this->to;
- } elseif ($this->video_service == 2) {
- $url = 'https://player.vimeo.com/video/' . $this->to;
- } elseif ($this->video_service == 3) {
- list($playerId, $videoId) = explode('|', $this->to);
- $url = 'https://link.brightcove.com/services/player/bcpid' . $playerId . '?bctid=' . $videoId . '&autoStart=false&width=100%25&height=100%25';
+ switch ($data->video_service) {
+ case 0:
+ return 'https://www.youtube.com/embed/' . $data->to . '?html5=1';
+ case 1:
+ return 'https://www.dailymotion.com/embed/video/' . $data->to;
+ case 2:
+ return 'https://player.vimeo.com/video/' . $data->to;
+ case 3:
+ default:
+ return $data->to;
}
- return $url;
}
+ public static function makeVideoTag($link, $width, $height, $compiler)
+ {
+ if ($link->video_service === 0) {
+ return videoLink::makeVideoTag($link, $width, $height, $compiler);
+ }
+ return self::getEmbed($link);
+ }
}
class actionLink extends internalLink
class webVideoPopupLink extends videoPopupLink
{
- // public function getURL() {
- // if ($this->video_service == 0) {
- // $service = 'youtube';
- // } elseif ($this->video_service == 1) {
- // $service = 'dailymotion';
- // } elseif ($this->video_service == 2) {
- // $service = 'vimeo';
- // } elseif ($this->video_service == 3) {
- // $service = 'brightcove';
- // }
- // return '#/webvideo/' . $service . '/' . $this->to;
- // }
-
public function getURL()
{
-
switch ($this->video_service) {
case 1: // Dailymotion
return '#/webvideo/dailymotion/' . $this->to;
- break;
case 2: // Vimeo
return '#/webvideo/vimeo/' . $this->to;
- break;
+ case 3: // Brightcove
+ return '#/webvideo/brightcove/' . md5($this->to);
default:
return '#/video/' . $this->to;
}