68 $main_tpl = $this->gui->ui()->mainTemplate();
69
70 $ctrl = $this->gui->ctrl();
71
73
74 if (is_null($med) || !$this->media_type->isAudio($med->getFormat())) {
75 return null;
76 }
77
78 if ($med->getLocationType() === "Reference") {
79 $resource = $med->getLocation();
80 } else {
82 $resource = $path_to_file;
83 }
84
85 $audio = $this->gui->ui()->factory()->player()->audio(
86 $resource,
87 ""
88 );
89
90 if ($tracking_container_ref_id > 0) {
91
93 $treshold = (
int) $mcst_settings->getVideoCompletionThreshold();
94
95 $main_tpl->addJavaScript("./Services/MediaObjects/js/MediaObjectsCompletion.js");
96 $ctrl->setParameter($this, "mob_tracking_ref_id", $tracking_container_ref_id);
97 $ctrl->setParameter($this,
"mob_tracking_mob_id", $mob->
getId());
98 $url = $ctrl->getLinkTarget($this,
"saveCompletion");
99 $audio = $audio->withAdditionalOnLoadCode(
function (
$id) use (
$url, $treshold) {
100 $js = <<<EOT
101 document.getElementById('$id').dataset.mobCompletionCallback = '$url';
102 document.getElementById('$id').dataset.mobCompletionThreshold = '$treshold';
103 il.MediaObjectsCompletion.init();
104EOT;
105 return $js;
106 });
107 }
108 return $audio;
109 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins