use Cubist\Util\Json;
use Cubist\Util\ObjectUtil;
use Cubist\Util\Text;
+use Cubist\Util\WebVideo;
use Cubist\Util\Xml;
use Fluidbook\Tools\Compiler\CompilerInterface;
use Illuminate\Support\Facades\Cache;
public $transition;
public $polygon = '';
public $cursor = '';
- public $blinkdelay=0;
+ public $blinkdelay = 0;
protected $role = 'button';
return CustomLink::getCustomInstance($id, $init, $compiler);
case static::WEBVIDEO:
$init['inline'] = self::normalizeInlineIntegration($init['inline']);
+ $init['to'] = WebVideoLink::cleanID($init['to']);
if ($init['inline'] === 'popup') {
return new WebVideoPopupLink($id, $init, $compiler);
}
namespace Fluidbook\Tools\Links;
-class WebVideoLink extends VideoLink {
+class WebVideoLink extends VideoLink
+{
- protected static $_useVideoJS = ['youtube', 'dailymotion', 'vimeo'];
+ protected static $_useVideoJS = ['youtube', 'dailymotion'];
- public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) {
+ public static function cleanID($id)
+ {
+ $id = str_replace('https://vimeo.com/', '', $id);
+ $id = str_replace('https://player.vimeo.com/video/', '', $id);
+ $id = trim($id, '/ ');
+ return $id;
+ }
+
+ public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null)
+ {
$attributes = parent::getVideoAttributes($data, $w, $h, $compiler);
// Since the admin interface doesn't offer options for setting controls or sound, we will set some defaults here
return $attributes;
}
- protected static function _normalizeVideoService($vs) {
+ protected static function _normalizeVideoService($vs)
+ {
if ($vs == 0) {
return 'youtube';
} else if ($vs == 1) {
/**
* @throws \JsonException
*/
- public static function getVideoSetup($data, $compiler) {
+ public static function getVideoSetup($data, $compiler)
+ {
if (!self::supportVideoJS($data->video_service)) {
return '[]';
}
}
- public function getHTMLContent() {
+ public function getHTMLContent()
+ {
if (!self::supportVideoJS($this->video_service)) {
return self::getEmbed($this);
}
return self::makeVideoTag($this, $w, $h, $this->compiler);
}
- public static function getEmbed($link, $width = null, $height = null) {
+ public static function getEmbed($link, $width = null, $height = null)
+ {
if (null === $width) {
$width = $link->width;
}
return '<iframe width="' . $width . '" height="' . $height . '" src="' . self::getEmbedURL($link) . '" frameborder="0" allowfullscreen allow="autoplay; fullscreen"></iframe>';
}
- public static function getEmbedURL($data) {
+ public static function getEmbedURL($data)
+ {
$muted = (!$data->video_sound_on) ? '1' : '0';
$autoplay = $data->video_auto_start ? '1' : '0';
$loop = $data->video_loop ? '1' : '0';
case 'dailymotion':
return 'https://www.dailymotion.com/embed/video/' . $data->to;
case 'vimeo':
- return 'https://player.vimeo.com/video/' . $data->to . '?autoplay=' . $autoplay . '&loop=' . $loop . '&muted=' . $muted;
+ $u = parse_url($data->to);
+ $id = $u['path'];
+ $url = 'https://player.vimeo.com/video/' . $id;
+ parse_str($u['query'], $params);
+ $params['autoplay'] = $autoplay;
+ $params['loop'] = $loop;
+ $params['muted'] = $muted;
+ $url .= '?' . http_build_query($params);
+ if (isset($u['fragment']) && $u['fragment'] != '') {
+ $url .= '#' . $u['fragment'];
+ }
+ return $url;
default:
return $data->to;
}
}
- public static function makeVideoTag($link, $width = null, $height = null, $compiler = null) {
+ public static function makeVideoTag($link, $width = null, $height = null, $compiler = null)
+ {
if (self::supportVideoJS($link->video_service)) {
return parent::makeVideoTag($link, $width, $height, $compiler);
return self::getEmbed($link);
}
- protected static function supportVideoJS($service) {
+ protected static function supportVideoJS($service)
+ {
return in_array(self::_normalizeVideoService($service), self::$_useVideoJS);
}
}