|
1
|
|
|
<?php |
|
2
|
|
|
/** @formatter:off |
|
3
|
|
|
* ****************************************************************** |
|
4
|
|
|
* Created by Marko Kungla on Jul 3, 2016 - 7:08:14 PM |
|
5
|
|
|
* Contact [email protected] |
|
6
|
|
|
* @copyright 2016 Marko Kungla - https://github.com/mkungla |
|
7
|
|
|
* @license The MIT License (MIT) |
|
8
|
|
|
* |
|
9
|
|
|
* @category AframeVR |
|
10
|
|
|
* @package aframe-php |
|
11
|
|
|
* |
|
12
|
|
|
* Lang PHP (php version >= 7) |
|
13
|
|
|
* Encoding UTF-8 |
|
14
|
|
|
* File AssetVideo.php |
|
15
|
|
|
* Code format PSR-2 and 12 |
|
16
|
|
|
* @link https://github.com/mkungla/aframe-php |
|
17
|
|
|
* @issues https://github.com/mkungla/aframe-php/issues |
|
18
|
|
|
* ******************************************************************** |
|
19
|
|
|
* Contributors: |
|
20
|
|
|
* @author Marko Kungla <[email protected]> |
|
21
|
|
|
* ******************************************************************** |
|
22
|
|
|
* Comments: |
|
23
|
|
|
* @formatter:on */ |
|
24
|
|
|
namespace AframeVR\Core\Assets; |
|
25
|
|
|
|
|
26
|
|
|
use \AframeVR\Interfaces\Core\Assets\AssetVideoInterface; |
|
27
|
|
|
use \AframeVR\Core\Helpers\AssetsAbstract; |
|
28
|
|
|
|
|
29
|
|
|
final class AssetVideo extends AssetsAbstract implements AssetVideoInterface |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Autoplay video |
|
34
|
|
|
* |
|
35
|
|
|
* @var bool |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $attr_autoplay; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Preload video |
|
41
|
|
|
* |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $attr_preload; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Image crossorigin |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $attr_crossorigin; |
|
52
|
|
|
|
|
53
|
1 |
|
public function init() |
|
54
|
|
|
{ |
|
55
|
1 |
|
$this->setDomElementTag('video'); |
|
56
|
1 |
|
} |
|
57
|
|
|
/** |
|
58
|
|
|
* Autoplay video |
|
59
|
|
|
* |
|
60
|
|
|
* @param bool $autoplay |
|
61
|
|
|
* @return AssetVideoInterface |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function autoplay(bool $autoplay = true): AssetVideoInterface |
|
64
|
|
|
{ |
|
65
|
1 |
|
$this->attrs['autoplay'] = $autoplay ? 'true' : 'false'; |
|
66
|
1 |
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* loop video |
|
71
|
|
|
* |
|
72
|
|
|
* @param bool $loop |
|
73
|
|
|
* @return AssetVideoInterface |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function loop(bool $loop = true): AssetVideoInterface |
|
76
|
|
|
{ |
|
77
|
1 |
|
$this->attrs['loop'] = $loop ? 'true' : 'false'; |
|
78
|
1 |
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Preload video |
|
83
|
|
|
* |
|
84
|
|
|
* @param string $preload |
|
85
|
|
|
* @return AssetVideoInterface |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function preload(string $preload = 'auto'): AssetVideoInterface |
|
88
|
|
|
{ |
|
89
|
1 |
|
$this->attrs['preload'] = $preload; |
|
90
|
1 |
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Set crossorigin attribute of the video |
|
95
|
|
|
* |
|
96
|
|
|
* @param string $crossorigin |
|
97
|
|
|
* @return AssetVideoInterface |
|
98
|
|
|
*/ |
|
99
|
1 |
|
public function crossorigin(string $crossorigin = 'anonymous'): AssetVideoInterface |
|
100
|
|
|
{ |
|
101
|
1 |
|
$this->attrs['crossorigin'] = $crossorigin; |
|
102
|
1 |
|
return $this; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|