ILIAS  release_8 Revision v8.23
class.VideoSequence.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\MediaCast\Video;
20 
26 {
27  protected \ilObjMediaCast $media_cast;
29  protected array $videos;
30 
31  public function __construct(\ilObjMediaCast $cast)
32  {
33  $this->media_cast = $cast;
34  $this->init();
35  }
36 
37  protected function init(): void
38  {
39  $videos = [];
40  foreach ($this->media_cast->getSortedItemsArray() as $item) {
41  $mob = new \ilObjMediaObject($item["mob_id"]);
42  $med = $mob->getMediaItem("Standard");
43  $title = $item["title"];
44  $time = (int) $item["playtime"];
45  $preview_pic = "";
46  if ($mob->getVideoPreviewPic() != "") {
47  $preview_pic = $mob->getVideoPreviewPic();
48  }
49 
50  $mime = '';
51  $resource = '';
52 
53  if (is_object($med)) {
54  if (strcasecmp("Reference", $med->getLocationType()) == 0) {
55  $resource = $med->getLocation();
56  } else {
57  $path_to_file = \ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
58  $resource = $path_to_file;
59  }
60  $mime = $med->getFormat();
61  }
62  if (in_array($mime, ["video/vimeo", "video/youtube"])) {
63  if (!is_int(strpos($resource, "?"))) {
64  $resource .= "?controls=0";
65  } else {
66  $resource .= "&controls=0";
67  }
68  }
69  if (in_array($mime, ["video/mp4", "video/vimeo", "video/youtube"])) {
70  $videos[] = new VideoItem(
71  $item["mob_id"],
72  $title,
73  $time,
74  $mime,
75  $resource,
76  $preview_pic,
77  (string) $item["content"],
78  (string) $item["playtime"],
79  $med->getDuration()
80  );
81  }
82  }
83  $this->videos = $videos;
84  }
85 
89  public function getVideos(): array
90  {
91  return $this->videos;
92  }
93 
94  public function getFirst(): ?VideoItem
95  {
96  if (count($this->videos) > 0) {
97  return $this->videos[0];
98  }
99  return null;
100  }
101 }
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...
static _getURL(int $a_mob_id)
get directory for files of media object