Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
video.php
1<?php
2
4
7
8class Video extends Renderer
9{
10 const WIDTH = 700;
11 const HEIGHT = 700;
12
13 const JS_TYPE_VIDEO = 'video';
14
15 public function getWidth()
16 {
17 return $this->getOption('width', self::WIDTH);
18 }
19
20 public function getHeight()
21 {
22 return $this->getOption('height', self::HEIGHT);
23 }
24
25 public static function getJsType()
26 {
28 }
29
30 public static function getAllowedContentTypes()
31 {
32 return [
33 'video/mp4',
34 'video/x-flv',
35 'video/webm',
36 'video/ogg',
37 'video/quicktime',
38 ];
39 }
40
41 public function render()
42 {
43 Loader::includeModule('fileman');
44
45 return \CJSCore::getHTML(['player']);
46 }
47
48 public function getData()
49 {
50 $data = [
51 'width' => $this->getWidth(),
52 'height' => $this->getHeight(),
53 'contentType' => $this->getOption('contentType'),
54 'src' => $this->sourceUri,
55 ];
56
57 $sources = [
58 [
59 'src' => $this->sourceUri,
60 'type' => $this->getOption('contentType'),
61 ]
62 ];
63 $sources = $this->modifySourcesByDirtyHacks($sources);
64
65 $altSrc = $this->getOption('alt.sourceUri');
66 if ($altSrc)
67 {
68 array_unshift($sources, [
69 'src' => $altSrc,
70 'type' => $this->getOption('alt.contentType'),
71 ]);
72 }
73 $data['sources'] = $sources;
74
75 return $data;
76 }
77
78 protected function modifySourcesByDirtyHacks(array $sources)
79 {
80 $updatedSources = $sources;
81 foreach ($sources as $source)
82 {
83 if ($source['type'] === 'video/quicktime')
84 {
85 //some browser can work with quicktime :)
87 $src = clone $source['src'];
88 $src->addParams(['fakeUnique' => 'qt',]);
89
90 $updatedSources[] = [
91 'src' => $src,
92 'type' => 'video/mp4',
93 ];
94 }
95 }
96
97 return $updatedSources;
98 }
99}
static includeModule($moduleName)
Definition loader.php:69
getOption($name, $defaultValue=null)
Definition renderer.php:25