1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MovingImage\Client\VMPro\Entity; |
6
|
|
|
|
7
|
|
|
use DateTime; |
8
|
|
|
use JMS\Serializer\Annotation\Type; |
9
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
10
|
|
|
use MovingImage\Meta\Interfaces\VideoInterface; |
11
|
|
|
|
12
|
|
|
class Video implements VideoInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @Type("string") |
16
|
|
|
*/ |
17
|
|
|
private $id; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @Type("string") |
21
|
|
|
*/ |
22
|
|
|
private $title; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @Type("string") |
26
|
|
|
*/ |
27
|
|
|
private $description; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @Type("string") |
31
|
|
|
*/ |
32
|
|
|
private $thumbnail; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @Type("integer") |
36
|
|
|
*/ |
37
|
|
|
private $length; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @Type("integer") |
41
|
|
|
* @SerializedName("createdDate") |
42
|
|
|
*/ |
43
|
|
|
private $createdDate; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @Type("integer") |
47
|
|
|
* @SerializedName("modifiedDate") |
48
|
|
|
*/ |
49
|
|
|
private $modifiedDate; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @Type("integer") |
53
|
|
|
* @SerializedName("uploadDate") |
54
|
|
|
*/ |
55
|
|
|
private $uploadDate; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Type("integer") |
59
|
|
|
*/ |
60
|
|
|
private $generation; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @Type("integer") |
64
|
|
|
*/ |
65
|
|
|
private $plays; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @Type("integer") |
69
|
|
|
*/ |
70
|
|
|
private $views; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @Type("boolean") |
74
|
|
|
* @SerializedName("allFormatsAvailable") |
75
|
|
|
*/ |
76
|
|
|
private $allFormatsAvailable; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @TODO replace it with array collection |
80
|
|
|
* |
81
|
|
|
* @Type("array") |
82
|
|
|
* @SerializedName("customMetadata") |
83
|
|
|
*/ |
84
|
|
|
private $customMetadata; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @TODO replace it with array collection |
88
|
|
|
* |
89
|
|
|
* @Type("array") |
90
|
|
|
*/ |
91
|
|
|
private $keywords; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @TODO replace it with array collection |
95
|
|
|
* |
96
|
|
|
* @Type("array") |
97
|
|
|
*/ |
98
|
|
|
private $stills; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @Type("boolean") |
102
|
|
|
*/ |
103
|
|
|
private $published; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @Type("array") |
107
|
|
|
*/ |
108
|
|
|
private $channels; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @Type("string") |
112
|
|
|
* @SerializedName("uploadFileName") |
113
|
|
|
*/ |
114
|
|
|
private $uploadFileName; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @Type("boolean") |
118
|
|
|
*/ |
119
|
|
|
private $downloadable; |
120
|
|
|
|
121
|
|
|
public function setId(string $id): self |
122
|
|
|
{ |
123
|
|
|
$this->id = $id; |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function getId(): string |
129
|
|
|
{ |
130
|
|
|
return $this->id; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getTitle(): ?string |
134
|
|
|
{ |
135
|
|
|
return $this->title; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function setTitle(string $title): self |
139
|
|
|
{ |
140
|
|
|
$this->title = $title; |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function getDescription(): ?string |
146
|
|
|
{ |
147
|
|
|
return $this->description; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function setDescription(string $description): self |
151
|
|
|
{ |
152
|
|
|
$this->description = $description; |
153
|
|
|
|
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getThumbnail(): ?string |
158
|
|
|
{ |
159
|
|
|
return $this->thumbnail; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function setThumbnail(string $thumbnail): self |
163
|
|
|
{ |
164
|
|
|
$this->thumbnail = $thumbnail; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function getLength(): ?int |
170
|
|
|
{ |
171
|
|
|
return $this->length; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
public function setLength(int $length): self |
175
|
|
|
{ |
176
|
|
|
$this->length = $length; |
177
|
|
|
|
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function getCreatedDate(): DateTime |
182
|
|
|
{ |
183
|
|
|
$date = new DateTime(); |
184
|
|
|
$date->setTimestamp(floor($this->createdDate / 1000)); |
185
|
|
|
|
186
|
|
|
return $date; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public function setCreatedDate(DateTime $createdDate): Video |
190
|
|
|
{ |
191
|
|
|
$this->createdDate = $createdDate->getTimestamp() * 1000; |
192
|
|
|
|
193
|
|
|
return $this; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
public function getModifiedDate(): ?DateTime |
197
|
|
|
{ |
198
|
|
|
$date = new DateTime(); |
199
|
|
|
$date->setTimestamp(floor($this->modifiedDate / 1000)); |
200
|
|
|
|
201
|
|
|
return $date; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
public function setModifiedDate(DateTime $modifiedDate): self |
205
|
|
|
{ |
206
|
|
|
$this->modifiedDate = $modifiedDate->getTimestamp() * 1000; |
207
|
|
|
|
208
|
|
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
public function getUploadDate(): ?DateTime |
212
|
|
|
{ |
213
|
|
|
$date = new DateTime(); |
214
|
|
|
$date->setTimestamp(floor($this->uploadDate / 1000)); |
215
|
|
|
|
216
|
|
|
return $date; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
public function setUploadDate(DateTime $uploadDate): self |
220
|
|
|
{ |
221
|
|
|
$this->uploadDate = $uploadDate->getTimestamp() * 1000; |
222
|
|
|
|
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
public function getGeneration(): ?int |
227
|
|
|
{ |
228
|
|
|
return $this->generation; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
public function setGeneration(int $generation): self |
232
|
|
|
{ |
233
|
|
|
$this->generation = $generation; |
234
|
|
|
|
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
public function getPlays(): ?int |
239
|
|
|
{ |
240
|
|
|
return $this->plays; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
public function setPlays(int $plays): self |
244
|
|
|
{ |
245
|
|
|
$this->plays = $plays; |
246
|
|
|
|
247
|
|
|
return $this; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
public function getViews(): ?int |
251
|
|
|
{ |
252
|
|
|
return $this->views; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
public function setViews(int $views): self |
256
|
|
|
{ |
257
|
|
|
$this->views = $views; |
258
|
|
|
|
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function areAllFormatsAvailable(): bool |
263
|
|
|
{ |
264
|
|
|
return $this->allFormatsAvailable; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
public function setAllFormatsAvailable(bool $allFormatsAvailable): self |
268
|
|
|
{ |
269
|
|
|
$this->allFormatsAvailable = $allFormatsAvailable; |
270
|
|
|
|
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
public function getCustomMetadata(): ?array |
275
|
|
|
{ |
276
|
|
|
return $this->customMetadata; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
public function setCustomMetadata(array $customMetadata): self |
280
|
|
|
{ |
281
|
|
|
$this->customMetadata = $customMetadata; |
282
|
|
|
|
283
|
|
|
return $this; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
public function getKeywords(): array |
287
|
|
|
{ |
288
|
|
|
return $this->keywords; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
public function setKeywords(array $keywords): self |
292
|
|
|
{ |
293
|
|
|
$this->keywords = $keywords; |
294
|
|
|
|
295
|
|
|
return $this; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
public function getStills(): array |
299
|
|
|
{ |
300
|
|
|
//sorting preview's images from smallest to biggest |
301
|
|
|
usort($this->stills, function (array $item1, array $item2) { |
302
|
|
|
if (isset($item1['dimension']['height'], $item2['dimension']['height']) && $item1['dimension']['height'] != $item2['dimension']['height']) { |
303
|
|
|
return ($item1['dimension']['height'] > $item2['dimension']['height']) ? 1 : -1; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
return 0; |
307
|
|
|
}); |
308
|
|
|
|
309
|
|
|
return $this->stills; |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
public function setStills(array $stills): self |
313
|
|
|
{ |
314
|
|
|
$this->stills = $stills; |
315
|
|
|
|
316
|
|
|
return $this; |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
public function setPublished(bool $published): self |
320
|
|
|
{ |
321
|
|
|
$this->published = $published; |
322
|
|
|
|
323
|
|
|
return $this; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
public function isPublished(): ?bool |
327
|
|
|
{ |
328
|
|
|
return $this->published; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
public function setDownloadable(bool $downloadable): self |
332
|
|
|
{ |
333
|
|
|
$this->downloadable = $downloadable; |
334
|
|
|
|
335
|
|
|
return $this; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
public function isDownloadable(): ?bool |
339
|
|
|
{ |
340
|
|
|
return $this->downloadable; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
public function getStatus(): int |
344
|
|
|
{ |
345
|
|
|
return $this->isPublished() |
346
|
|
|
? VideoInterface::STATUS_PUBLISHED |
347
|
|
|
: VideoInterface::STATUS_NOT_PUBLISHED; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
public function getChannels(): array |
351
|
|
|
{ |
352
|
|
|
return $this->channels; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
public function setChannels(array $channels): self |
356
|
|
|
{ |
357
|
|
|
$this->channels = $channels; |
358
|
|
|
|
359
|
|
|
return $this; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
public function getUploadFileName(): string |
363
|
|
|
{ |
364
|
|
|
return $this->uploadFileName; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
public function setUploadFileName(string $uploadFileName): self |
368
|
|
|
{ |
369
|
|
|
$this->uploadFileName = $uploadFileName; |
370
|
|
|
|
371
|
|
|
return $this; |
372
|
|
|
} |
373
|
|
|
} |
374
|
|
|
|