ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMediaObjectsPlayerWrapperGUI Class Reference
+ Collaboration diagram for ilMediaObjectsPlayerWrapperGUI:

Public Member Functions

 __construct (InternalDomainService $domain_service, InternalGUIService $gui_service)
 
 executeCommand ()
 
 renderComponent (ilObjMediaObject $mob, int $tracking_container_ref_id=0)
 
 getComponent (ilObjMediaObject $mob, int $tracking_container_ref_id=0)
 
 audio (ilObjMediaObject $mob, int $tracking_container_ref_id=0)
 
 image (ilObjMediaObject $mob, int $tracking_container_ref_id=0)
 
 video (ilObjMediaObject $mob, int $tracking_container_ref_id=0)
 

Protected Member Functions

 saveCompletion ()
 

Protected Attributes

ILIAS MediaObjects Tracking TrackingManager $tracking
 
ILIAS MediaObjects Player PlayerGUIRequest $request
 
ILIAS MediaObjects MediaType MediaTypeManager $media_type
 
InternalGUIService $gui
 
InternalDomainService $domain
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMediaObjectsPlayerWrapperGUI::__construct ( InternalDomainService  $domain_service,
InternalGUIService  $gui_service 
)

Definition at line 35 of file class.ilMediaObjectsPlayerWrapperGUI.php.

38 {
39 $this->gui = $gui_service;
40 $this->domain = $domain_service;
41 $this->media_type = $this->domain->mediaType();
42 $this->request = $gui_service->player()->request();
43 $this->tracking = $this->domain->tracking();
44 }

References ILIAS\MediaObjects\InternalDomainService\mediaType(), and ILIAS\MediaObjects\InternalGUIService\player().

+ Here is the call graph for this function:

Member Function Documentation

◆ audio()

ilMediaObjectsPlayerWrapperGUI::audio ( ilObjMediaObject  $mob,
int  $tracking_container_ref_id = 0 
)
Exceptions
ilCtrlException

Definition at line 101 of file class.ilMediaObjectsPlayerWrapperGUI.php.

105 $main_tpl = $this->gui->ui()->mainTemplate();
106
107 $ctrl = $this->gui->ctrl();
108
109 $med = $mob->getMediaItem("Standard");
110
111 if (is_null($med) || !$this->media_type->isAudio($med->getFormat())) {
112 return null;
113 }
114 $resource = $mob->getStandardSrc();
115 $audio = $this->gui->ui()->factory()->player()->audio(
116 $resource,
117 ""
118 );
119
120 if ($tracking_container_ref_id > 0) {
121 // @todo: make this a media object general setting
122 $mcst_settings = ilMediaCastSettings::_getInstance();
123 $treshold = (int) $mcst_settings->getVideoCompletionThreshold();
124
125 $main_tpl->addJavaScript("assets/js/MediaObjectsCompletion.js");
126 $ctrl->setParameter($this, "mob_tracking_ref_id", $tracking_container_ref_id);
127 $ctrl->setParameter($this, "mob_tracking_mob_id", $mob->getId());
128 $url = $ctrl->getLinkTarget($this, "saveCompletion");
129 $audio = $audio->withAdditionalOnLoadCode(function ($id) use ($url, $treshold) {
130 $js = <<<EOT
131 document.getElementById('$id').dataset.mobCompletionCallback = '$url';
132 document.getElementById('$id').dataset.mobCompletionThreshold = '$treshold';
133 il.MediaObjectsCompletion.init();
134EOT;
135 return $js;
136 });
137 }
138 return $audio;
139 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getMediaItem(string $a_purpose)
get item for media purpose
$url
Definition: shib_logout.php:68

Referenced by getComponent().

+ Here is the caller graph for this function:

◆ executeCommand()

ilMediaObjectsPlayerWrapperGUI::executeCommand ( )

Definition at line 46 of file class.ilMediaObjectsPlayerWrapperGUI.php.

46 : void
47 {
48 $ctrl = $this->gui->ctrl();
49
50 $next_class = $ctrl->getNextClass($this);
51 $cmd = $ctrl->getCmd();
52
53 switch ($next_class) {
54 default:
55 if (in_array($cmd, array("saveCompletion"))) {
56 $this->$cmd();
57 }
58 }
59 }

◆ getComponent()

ilMediaObjectsPlayerWrapperGUI::getComponent ( ilObjMediaObject  $mob,
int  $tracking_container_ref_id = 0 
)

Definition at line 71 of file class.ilMediaObjectsPlayerWrapperGUI.php.

74 {
75 $med = $mob->getMediaItem("Standard");
76 $comp = null;
77 if (!is_null($med)) {
78 if ($this->media_type->isAudio($med->getFormat())) {
79 $comp = $this->audio(
80 $mob,
81 $tracking_container_ref_id
82 );
83 } elseif ($this->media_type->isVideo($med->getFormat())) {
84 $comp = $this->video(
85 $mob,
86 $tracking_container_ref_id
87 );
88 } elseif ($this->media_type->isImage($med->getFormat())) {
89 $comp = $this->image(
90 $mob,
91 $tracking_container_ref_id
92 );
93 }
94 }
95 return $comp;
96 }
video(ilObjMediaObject $mob, int $tracking_container_ref_id=0)
image(ilObjMediaObject $mob, int $tracking_container_ref_id=0)
audio(ilObjMediaObject $mob, int $tracking_container_ref_id=0)
A component is the most general form of an entity in the UI.
Definition: Component.php:28

References audio(), ilObjMediaObject\getMediaItem(), image(), and video().

Referenced by renderComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ image()

ilMediaObjectsPlayerWrapperGUI::image ( ilObjMediaObject  $mob,
int  $tracking_container_ref_id = 0 
)
Exceptions
ilCtrlException

Definition at line 144 of file class.ilMediaObjectsPlayerWrapperGUI.php.

148 $main_tpl = $this->gui->ui()->mainTemplate();
149
150 $ctrl = $this->gui->ctrl();
151
152 $med = $mob->getMediaItem("Standard");
153
154 if (is_null($med) || !$this->media_type->isImage($med->getFormat())) {
155 return null;
156 }
157
158 $source = $mob->getStandardSrc();
159
160 $image = $this->gui->ui()->factory()->image()->responsive($source, $mob->getTitle());
161
162 if ($tracking_container_ref_id > 0) {
163 // @todo: make this a media object general setting
164 $mcst_settings = ilMediaCastSettings::_getInstance();
165 $treshold = (int) $mcst_settings->getVideoCompletionThreshold();
166
167 $main_tpl->addJavaScript("assets/js/MediaObjectsCompletion.js");
168 $ctrl->setParameter($this, "mob_tracking_ref_id", $tracking_container_ref_id);
169 $ctrl->setParameter($this, "mob_tracking_mob_id", $mob->getId());
170 $url = $ctrl->getLinkTarget($this, "saveCompletion");
171 $audio = $image->withAdditionalOnLoadCode(function ($id) use ($url, $treshold) {
172 $js = <<<EOT
173 document.getElementById('$id').dataset.mobCompletionCallback = '$url';
174 document.getElementById('$id').dataset.mobCompletionThreshold = '$treshold';
175 il.MediaObjectsCompletion.init();
176EOT;
177 return $js;
178 });
179 }
180 return $image;
181 }

Referenced by getComponent().

+ Here is the caller graph for this function:

◆ renderComponent()

ilMediaObjectsPlayerWrapperGUI::renderComponent ( ilObjMediaObject  $mob,
int  $tracking_container_ref_id = 0 
)

Definition at line 61 of file class.ilMediaObjectsPlayerWrapperGUI.php.

63 : string
64 {
65 $comp = $this->getComponent($mob, $tracking_container_ref_id);
66 if ($comp) {
67 return $this->gui->ui()->renderer()->render($comp);
68 }
69 return "";
70 }
getComponent(ilObjMediaObject $mob, int $tracking_container_ref_id=0)

References getComponent().

+ Here is the call graph for this function:

◆ saveCompletion()

ilMediaObjectsPlayerWrapperGUI::saveCompletion ( )
protected

Definition at line 228 of file class.ilMediaObjectsPlayerWrapperGUI.php.

228 : void
229 {
230 $ref_id = $this->request->getTrackingRefId();
231 $mob_id = $this->request->getTrackingMobId();
232 $this->tracking->saveCompletion($mob_id, $ref_id);
233 }
$ref_id
Definition: ltiauth.php:66

References $ref_id.

◆ video()

ilMediaObjectsPlayerWrapperGUI::video ( ilObjMediaObject  $mob,
int  $tracking_container_ref_id = 0 
)
Exceptions
ilCtrlException

Definition at line 186 of file class.ilMediaObjectsPlayerWrapperGUI.php.

190 $main_tpl = $this->gui->ui()->mainTemplate();
191
192 $ctrl = $this->gui->ctrl();
193
194 $med = $mob->getMediaItem("Standard");
195
196 if (is_null($med) || !$this->media_type->isVideo($med->getFormat())) {
197 return null;
198 }
199
200 $source = $mob->getStandardSrc();
201
202 $video = $this->gui->ui()->factory()->player()->video(
203 $source,
204 ""
205 );
206
207 if ($tracking_container_ref_id > 0) {
208 // @todo: make this a media object general setting
209 $mcst_settings = ilMediaCastSettings::_getInstance();
210 $treshold = (int) $mcst_settings->getVideoCompletionThreshold();
211
212 $main_tpl->addJavaScript("assets/js/MediaObjectsCompletion.js");
213 $ctrl->setParameter($this, "mob_tracking_ref_id", $tracking_container_ref_id);
214 $ctrl->setParameter($this, "mob_tracking_mob_id", $mob->getId());
215 $url = $ctrl->getLinkTarget($this, "saveCompletion");
216 $audio = $video->withAdditionalOnLoadCode(function ($id) use ($url, $treshold) {
217 $js = <<<EOT
218 document.getElementById('$id').dataset.mobCompletionCallback = '$url';
219 document.getElementById('$id').dataset.mobCompletionThreshold = '$treshold';
220 il.MediaObjectsCompletion.init();
221EOT;
222 return $js;
223 });
224 }
225 return $video;
226 }
Interface for Video elements.
Definition: Video.php:30

Referenced by getComponent().

+ Here is the caller graph for this function:

Field Documentation

◆ $domain

InternalDomainService ilMediaObjectsPlayerWrapperGUI::$domain
protected

Definition at line 33 of file class.ilMediaObjectsPlayerWrapperGUI.php.

◆ $gui

InternalGUIService ilMediaObjectsPlayerWrapperGUI::$gui
protected

Definition at line 32 of file class.ilMediaObjectsPlayerWrapperGUI.php.

◆ $media_type

ILIAS MediaObjects MediaType MediaTypeManager ilMediaObjectsPlayerWrapperGUI::$media_type
protected

Definition at line 31 of file class.ilMediaObjectsPlayerWrapperGUI.php.

◆ $request

ILIAS MediaObjects Player PlayerGUIRequest ilMediaObjectsPlayerWrapperGUI::$request
protected

Definition at line 30 of file class.ilMediaObjectsPlayerWrapperGUI.php.

◆ $tracking

ILIAS MediaObjects Tracking TrackingManager ilMediaObjectsPlayerWrapperGUI::$tracking
protected

Definition at line 29 of file class.ilMediaObjectsPlayerWrapperGUI.php.


The documentation for this class was generated from the following file: