|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component; |
|
6
|
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\APLComponentType; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\AudioTrack; |
|
9
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Document\Scale; |
|
10
|
|
|
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\AbstractStandardCommand; |
|
11
|
|
|
|
|
12
|
|
|
class VideoComponent extends APLBaseComponent implements \JsonSerializable |
|
13
|
|
|
{ |
|
14
|
|
|
public const TYPE = APLComponentType::VIDEO; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param AudioTrack|null $audioTrack Audio track to play on |
|
18
|
|
|
* @param bool $autoplay If true, automatically start playing the video |
|
19
|
|
|
* @param bool $muted When true, mute the audio for the video |
|
20
|
|
|
* @param AbstractStandardCommand[]|null $onEnd Commands to run when the last video track is finished playing |
|
21
|
|
|
* @param AbstractStandardCommand[]|null $onPause Commands to run when the video switches from playing to paused |
|
22
|
|
|
* @param AbstractStandardCommand[]|null $onPlay Commands to run when the video switches from paused to playing |
|
23
|
|
|
* @param AbstractStandardCommand[]|null $onTimeUpdate Commands to run when the playback position changes |
|
24
|
|
|
* @param AbstractStandardCommand[]|null $onTrackUpdate Commands to run when the current video track changes |
|
25
|
|
|
* @param AbstractStandardCommand[]|null $onTrackReady Commands to run when the current track state changes to ready |
|
26
|
|
|
* @param AbstractStandardCommand[]|null $onTrackFail Commands to run when an error occurs and video player can't play the media |
|
27
|
|
|
* @param string[]|null $preserve Properties to save when reinflating the document |
|
28
|
|
|
* @param Scale|null $scale How the video should scale to fill the space |
|
29
|
|
|
* @param bool $screenLock When true, extend the document lifecycle when the video is playing |
|
30
|
|
|
* @param string|array|null $source Single video source URL |
|
31
|
|
|
* @param array|null $sources Array of video sources |
|
32
|
|
|
* @param string[]|null $trackChanges Properties to track and report changes in the visual context |
|
33
|
|
|
*/ |
|
34
|
12 |
|
public function __construct( |
|
35
|
|
|
public ?AudioTrack $audioTrack = null, |
|
36
|
|
|
public bool $autoplay = false, |
|
37
|
|
|
public bool $muted = false, |
|
38
|
|
|
public ?array $onEnd = null, |
|
39
|
|
|
public ?array $onPause = null, |
|
40
|
|
|
public ?array $onPlay = null, |
|
41
|
|
|
public ?array $onTimeUpdate = null, |
|
42
|
|
|
public ?array $onTrackUpdate = null, |
|
43
|
|
|
public ?array $onTrackReady = null, |
|
44
|
|
|
public ?array $onTrackFail = null, |
|
45
|
|
|
?array $preserve = null, |
|
46
|
|
|
public ?Scale $scale = null, |
|
47
|
|
|
public bool $screenLock = true, |
|
48
|
|
|
public string|array|null $source = null, |
|
49
|
|
|
public ?array $sources = null, |
|
50
|
|
|
?array $trackChanges = null, |
|
51
|
|
|
) { |
|
52
|
12 |
|
parent::__construct(type: self::TYPE, preserve: $preserve, trackChanges: $trackChanges); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
8 |
|
public function jsonSerialize(): array |
|
56
|
|
|
{ |
|
57
|
8 |
|
$data = parent::jsonSerialize(); |
|
58
|
|
|
|
|
59
|
8 |
|
$this->addEnum($data, 'audioTrack', $this->audioTrack); |
|
60
|
8 |
|
$this->addBooleanTrue($data, 'autoplay', $this->autoplay); |
|
61
|
8 |
|
$this->addBooleanTrue($data, 'muted', $this->muted); |
|
62
|
|
|
|
|
63
|
8 |
|
$this->addCommandArray($data, 'onEnd', $this->onEnd); |
|
64
|
8 |
|
$this->addCommandArray($data, 'onPause', $this->onPause); |
|
65
|
8 |
|
$this->addCommandArray($data, 'onPlay', $this->onPlay); |
|
66
|
8 |
|
$this->addCommandArray($data, 'onTimeUpdate', $this->onTimeUpdate); |
|
67
|
8 |
|
$this->addCommandArray($data, 'onTrackUpdate', $this->onTrackUpdate); |
|
68
|
8 |
|
$this->addCommandArray($data, 'onTrackReady', $this->onTrackReady); |
|
69
|
8 |
|
$this->addCommandArray($data, 'onTrackFail', $this->onTrackFail); |
|
70
|
|
|
|
|
71
|
8 |
|
$this->addNonEmptyArray($data, 'preserve', $this->preserve); |
|
72
|
8 |
|
$this->addEnum($data, 'scale', $this->scale); |
|
73
|
|
|
|
|
74
|
|
|
// screenLock only included when false (default true) |
|
75
|
8 |
|
if (!$this->screenLock) { |
|
76
|
2 |
|
$data['screenLock'] = false; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
8 |
|
if ($this->source !== null) { |
|
80
|
3 |
|
$data['source'] = $this->source; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
8 |
|
$this->addNonEmptyArray($data, 'sources', $this->sources); |
|
84
|
8 |
|
$this->addNonEmptyArray($data, 'trackChanges', $this->trackChanges); |
|
85
|
|
|
|
|
86
|
8 |
|
return $data; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param array<string,mixed> $data |
|
91
|
|
|
*/ |
|
92
|
8 |
|
private function addEnum(array &$data, string $key, ?\UnitEnum $enum): void |
|
|
|
|
|
|
93
|
|
|
{ |
|
94
|
8 |
|
if ($enum !== null) { |
|
95
|
3 |
|
$data[$key] = $enum->value; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param array<string,mixed> $data |
|
101
|
|
|
* @param AbstractStandardCommand[]|null $commands |
|
102
|
|
|
*/ |
|
103
|
8 |
|
private function addCommandArray(array &$data, string $key, ?array $commands): void |
|
104
|
|
|
{ |
|
105
|
8 |
|
if ($commands !== null && $commands !== []) { |
|
106
|
1 |
|
$data[$key] = $commands; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param array<string,mixed> $data |
|
112
|
|
|
* @param array<mixed>|null $arr |
|
113
|
|
|
*/ |
|
114
|
8 |
|
private function addNonEmptyArray(array &$data, string $key, ?array $arr): void |
|
115
|
|
|
{ |
|
116
|
8 |
|
if ($arr !== null && $arr !== []) { |
|
117
|
1 |
|
$data[$key] = $arr; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param array<string,mixed> $data |
|
123
|
|
|
*/ |
|
124
|
8 |
|
private function addBooleanTrue(array &$data, string $key, bool $value): void |
|
125
|
|
|
{ |
|
126
|
8 |
|
if ($value) { |
|
127
|
2 |
|
$data[$key] = true; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths