ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.VideoSequence.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\MediaCast\Video;
20
26{
27 protected \ILIAS\MediaObjects\MediaType\MediaTypeManager $media_types;
28 protected \ilObjMediaCast $media_cast;
30 protected array $videos;
31
32 public function __construct(\ilObjMediaCast $cast)
33 {
34 global $DIC;
35
36 $this->media_types = $DIC->mediaObjects()->internal()->domain()->mediaType();
37 $this->media_cast = $cast;
38 $this->init();
39 }
40
41 protected function init(): void
42 {
43 global $DIC;
44
45 $f = $DIC->ui()->factory();
46 $r = $DIC->ui()->renderer();
47
48 $videos = [];
49 foreach ($this->media_cast->getSortedItemsArray() as $item) {
50 $mob = new \ilObjMediaObject($item["mob_id"]);
51 $med = $mob->getMediaItem("Standard");
52 $title = $item["title"];
53 $time = (int) $item["playtime"];
54 $preview_pic = "";
55 if ($mob->getVideoPreviewPic() != "") {
56 $preview_pic = $mob->getVideoPreviewPic();
57 }
58
59 $mime = '';
60 $resource = '';
61
62 if (is_object($med)) {
63 $resource = $mob->getStandardSrc();
64 $mime = $med->getFormat();
65 }
66 if (in_array($mime, iterator_to_array($this->media_types->getAllowedVideoMimeTypes()), true)) {
67 $videos[] = new VideoItem(
68 $item["mob_id"],
69 $title,
70 $time,
71 $mime,
72 $resource,
73 $preview_pic,
74 (string) $item["content"],
75 (string) $item["playtime"],
76 $med->getDuration()
77 );
78 }
79 }
80 $this->videos = $videos;
81 }
82
86 public function getVideos(): array
87 {
88 return $this->videos;
89 }
90
91 public function getFirst(): ?VideoItem
92 {
93 if (count($this->videos) > 0) {
94 return $this->videos[0];
95 }
96 return null;
97 }
98}
ILIAS MediaObjects MediaType MediaTypeManager $media_types
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26