From a63115f6b8e60966728737d9cc1e0ad48f84b09b Mon Sep 17 00:00:00 2001 From: Maciej Klemarczyk Date: Sun, 29 Jul 2018 00:29:37 +0200 Subject: [PATCH] Video source type was fixed for using as source type instead of quality type. --- src/helpers/HtmlVideo.php | 1 - src/models/VideoSource.php | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/helpers/HtmlVideo.php b/src/helpers/HtmlVideo.php index 2243ebe..ccb9851 100644 --- a/src/helpers/HtmlVideo.php +++ b/src/helpers/HtmlVideo.php @@ -21,7 +21,6 @@ class HtmlVideo extends \yii\helpers\BaseHtml public static function beginVideo($id, $options = []) { $options['id'] = $id; - return static::beginTag('video', $options); } diff --git a/src/models/VideoSource.php b/src/models/VideoSource.php index 62df323..4a9b636 100644 --- a/src/models/VideoSource.php +++ b/src/models/VideoSource.php @@ -41,17 +41,29 @@ class VideoSource extends Model */ public $sourceOptions; + private static $qualityList = ['114p', '240p', '360p', '480p', '720p', '1080p', '1140p', '2160p', '4320p']; + private static $hdQualityList = ['720p', '1080p', '1140p', '2160p', '4320p']; + public function rules() { return [ [['source', 'title'], 'trim'], [['source', 'title'], 'required'], - ['type', 'default', 'value' => '720p'], - ['quality', 'default', 'value' => 'SD'], + ['quality', 'default', 'value' => '720p'], - ['type', 'in', 'range' => ['114p', '240p', '360p', '480p', '720p', '1080p', '1140p', '2160p', '4320p']], - ['quality', 'in', 'range' => ['SD', 'HD']], + ['quality', 'in', 'range' => ['114p', '240p', '360p', '480p', '720p', '1080p', '1140p', '2160p', '4320p']], + ['type', 'in', 'range' => ['video/mp4', 'video/webm', 'video/ogg', 'application/dash+xml', 'application/x-mpegURL']], ]; } + + public function getIsHdReady() + { + return false !== array_search($this->quality, self::$hdQualityList); + } + + public function getQualityOrder() + { + return array_search($this->quality, self::$qualityList); + } }