ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 $local = false;
62 if (is_object($med)) {
63 $resource = $mob->getStandardSrc();
64 if ($med->getLocationType() !== "Reference") {
65 $local = true;
66 }
67 $mime = $med->getFormat();
68 }
69 if (in_array($mime, iterator_to_array($this->media_types->getAllowedVideoMimeTypes()), true)) {
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 $local,
81 $item["id"]
82 );
83 }
84 }
85 $this->videos = $videos;
86 }
87
91 public function getVideos(): array
92 {
93 return $this->videos;
94 }
95
96 public function getFirst(): ?VideoItem
97 {
98 if (count($this->videos) > 0) {
99 return $this->videos[0];
100 }
101 return null;
102 }
103}
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