ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.VideoSequence.php
Go to the documentation of this file.
1 <?php
2 
19 namespace 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  $videos = [];
44  foreach ($this->media_cast->getSortedItemsArray() as $item) {
45  $mob = new \ilObjMediaObject($item["mob_id"]);
46  $med = $mob->getMediaItem("Standard");
47  $title = $item["title"];
48  $time = (int) $item["playtime"];
49  $preview_pic = "";
50  if ($mob->getVideoPreviewPic() != "") {
51  $preview_pic = $mob->getVideoPreviewPic();
52  }
53 
54  $mime = '';
55  $resource = '';
56 
57  if (is_object($med)) {
58  if (strcasecmp("Reference", $med->getLocationType()) == 0) {
59  $resource = $med->getLocation();
60  } else {
61  $path_to_file = \ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
62  $resource = $path_to_file;
63  }
64  $mime = $med->getFormat();
65  }
66  if (in_array($mime, ["video/vimeo", "video/youtube"])) {
67  if (!is_int(strpos($resource, "?"))) {
68  $resource .= "?controls=0";
69  } else {
70  $resource .= "&controls=0";
71  }
72  }
73  if (in_array($mime, iterator_to_array($this->media_types->getAllowedVideoMimeTypes()), true)) {
74  $videos[] = new VideoItem(
75  $item["mob_id"],
76  $title,
77  $time,
78  $mime,
79  $resource,
80  $preview_pic,
81  (string) $item["content"],
82  (string) $item["playtime"],
83  $med->getDuration()
84  );
85  }
86  }
87  $this->videos = $videos;
88  }
89 
93  public function getVideos(): array
94  {
95  return $this->videos;
96  }
97 
98  public function getFirst(): ?VideoItem
99  {
100  if (count($this->videos) > 0) {
101  return $this->videos[0];
102  }
103  return null;
104  }
105 }
global $DIC
Definition: feed.php:28
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...
ILIAS MediaObjects MediaType MediaTypeManager $media_types
static _getURL(int $a_mob_id)
get directory for files of media object