You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
998 B

<?php
/**
* Created by Error202
* Date: 06.07.2018
*/
namespace core\widgets;
use yii\base\Widget;
use core\helpers\VideoHelper;
class VideoWidget extends Widget
{
public $src;
public $width = 640;
public $height = 360;
public $style = "width: 100%";
public function run() {
$player = '';
switch (VideoHelper::identityProvider($this->src)) {
case 'youtube':
$id = VideoHelper::parseYoutubeUrl($this->src);
$player = '<iframe style="'.$this->style.'" width="'.$this->width.'" height="'.$this->height.'" src="https://www.youtube.com/embed/'.$id.'" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>';
break;
case 'vimeo':
$id = VideoHelper::parseVimeoUrl($this->src);
$player = '<iframe style="'.$this->style.'" src="https://player.vimeo.com/video/'.$id.'" width="'.$this->width.'" height="'.$this->height.'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
break;
}
return $player;
}
}