Skip to content

Commit 0fa50ed

Browse files
committed
media objects: preview pic in copage content
1 parent 9de9d68 commit 0fa50ed

File tree

9 files changed

+281
-88
lines changed

9 files changed

+281
-88
lines changed

Modules/MediaCast/classes/class.ilObjMediaCastGUI.php

+21-77
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ilObjMediaCastGUI extends ilObjectGUI
3434
{
3535
protected \ILIAS\MediaObjects\MediaType\MediaTypeManager $media_type;
3636
protected \ILIAS\MediaCast\InternalGUIService $gui;
37+
protected $video_gui;
3738
protected \ILIAS\MediaCast\MediaCastManager $mc_manager;
3839
protected ilPropertyFormGUI $form_gui;
3940
protected ilNewsItem $mcst_item;
@@ -87,6 +88,7 @@ public function __construct(
8788
->domain()->mediaCast();
8889
$this->gui = $DIC->mediaCast()->internal()->gui();
8990
$this->media_type = $DIC->mediaObjects()->internal()->domain()->mediaType();
91+
$this->video_gui = $DIC->mediaObjects()->internal()->gui()->video();
9092
}
9193

9294
public function executeCommand(): void
@@ -389,32 +391,15 @@ public function editCastItemObject(): void
389391

390392
$this->checkPermission("write");
391393

394+
$this->mcst_item = new ilNewsItem(
395+
$this->mc_request->getItemId()
396+
);
397+
392398
// conversion toolbar
393-
if (ilFFmpeg::enabled()) {
394-
$this->mcst_item = new ilNewsItem(
395-
$item_id
396-
);
397-
$mob = new ilObjMediaObject($this->mcst_item->getMobId());
398-
399-
$conv_cnt = 0;
400-
// we had other purposes as source as well, but
401-
// currently only "Standard" is implemented in the convertFile method
402-
$p = "Standard";
403-
$med = $mob->getMediaItem($p);
404-
if (is_object($med)) {
405-
if (ilFFmpeg::supportsImageExtraction($med->getFormat())) {
406-
// second
407-
$ni = new ilTextInputGUI($this->lng->txt("mcst_second"), "sec");
408-
$ni->setMaxLength(4);
409-
$ni->setSize(4);
410-
$ni->setValue(1);
411-
$ilToolbar->addInputItem($ni, true);
412-
413-
$ilToolbar->addFormButton($this->lng->txt("mcst_extract_preview_image"), "extractPreviewImage");
414-
$ilToolbar->setFormAction($ilCtrl->getFormAction($this));
415-
}
416-
}
417-
}
399+
$this->video_gui->addPreviewExtractionToToolbar(
400+
$this->mcst_item->getMobId(),
401+
self::class
402+
);
418403

419404
$this->initAddCastItemForm("edit");
420405
$this->getCastItemValues($item_id);
@@ -532,10 +517,12 @@ public function initAddCastItemForm(string $a_mode = "create"): void
532517
$this->form_gui->addItem($ne);
533518

534519
// preview picure
535-
$pp = new ilImageFileInputGUI($lng->txt("mcst_preview_picture"), "preview_pic");
536-
$pp->setSuffixes(array("png", "jpeg", "jpg"));
537-
$pp->setInfo($lng->txt("mcst_preview_picture_info") . " mp4, mp3, png, jp(e)g, gif");
538-
$this->form_gui->addItem($pp);
520+
$mob_id = 0;
521+
if ($a_mode !== "create") {
522+
$mcst_item = new ilNewsItem($this->mc_request->getItemId());
523+
$mob_id = $mcst_item->getMobId();
524+
}
525+
$this->video_gui->addPreviewInput($this->form_gui, $mob_id);
539526
}
540527
}
541528

@@ -564,14 +551,6 @@ public function getCastItemValues(int $item_id): void
564551
);
565552
$mob = new ilObjMediaObject($this->mcst_item->getMobId());
566553

567-
// preview
568-
$ppic = $mob->getVideoPreviewPic();
569-
if ($ppic != "") {
570-
$i = $this->form_gui->getItemByPostVar("preview_pic");
571-
$i->setImage($ppic);
572-
}
573-
574-
575554
$values = array();
576555
$mediaItems = $this->getMediaItems(
577556
$this->mc_request->getItemId()
@@ -635,10 +614,7 @@ public function saveCastItemObject(): void
635614
$mob->setDescription($description);
636615

637616
// save preview pic
638-
$prevpic = $this->form_gui->getInput("preview_pic");
639-
if ($prevpic["size"] > 0) {
640-
$mob->uploadVideoPreviewPic($prevpic);
641-
}
617+
$this->video_gui->savePreviewInput($this->form_gui, $mob->getId());
642618

643619
// determine duration for standard purpose
644620
$duration = $this->getDuration($file);
@@ -856,15 +832,7 @@ public function updateCastItemObject(): void
856832
$mob->setTitle($title);
857833
$mob->setDescription($description);
858834

859-
$prevpic = $this->form_gui->getInput("preview_pic");
860-
if ($prevpic["size"] > 0) {
861-
$mob->uploadVideoPreviewPic($prevpic);
862-
} else {
863-
$prevpici = $this->form_gui->getItemByPostVar("preview_pic");
864-
if ($prevpici->getDeletionFlag()) {
865-
$mob->removeAdditionalFile($mob->getVideoPreviewPic(true));
866-
}
867-
}
835+
$this->video_gui->savePreviewInput($this->form_gui, $mob->getId());
868836
}
869837
}
870838

@@ -1666,35 +1634,11 @@ public function showGallery(): void
16661634
public function extractPreviewImageObject(): void
16671635
{
16681636
$ilCtrl = $this->ctrl;
1669-
$add = "";
1670-
16711637
$this->checkPermission("write");
1672-
16731638
$this->mcst_item = new ilNewsItem($this->mc_request->getItemId());
1674-
$mob = new ilObjMediaObject($this->mcst_item->getMobId());
1675-
1676-
try {
1677-
$sec = $this->mc_request->getSeconds();
1678-
if ($sec < 0) {
1679-
$sec = 0;
1680-
}
1681-
1682-
$mob->generatePreviewPic(320, 240, $sec);
1683-
if ($mob->getVideoPreviewPic() !== "") {
1684-
$this->tpl->setOnScreenMessage('info', $this->lng->txt("mcst_image_extracted"), true);
1685-
} else {
1686-
$this->tpl->setOnScreenMessage('failure', $this->lng->txt("mcst_no_extraction_possible"), true);
1687-
}
1688-
} catch (ilException $e) {
1689-
if (DEVMODE == 1) {
1690-
$ret = ilFFmpeg::getLastReturnValues();
1691-
$add = (is_array($ret) && count($ret) > 0)
1692-
? "<br />" . implode("<br />", $ret)
1693-
: "";
1694-
}
1695-
$this->tpl->setOnScreenMessage('failure', $e->getMessage() . $add, true);
1696-
}
1697-
1639+
$this->video_gui->handleExtractionRequest(
1640+
$this->mcst_item->getMobId()
1641+
);
16981642
$ilCtrl->redirect($this, "editCastItem");
16991643
}
17001644

Services/COPage/xsl/page.xsl

+3
Original file line numberDiff line numberDiff line change
@@ -2850,6 +2850,9 @@
28502850
<xsl:if test="$width = '' and $height = ''">
28512851
<xsl:attribute name="style">max-width: 100%; width: 100%; max-height: 100%;</xsl:attribute>
28522852
</xsl:if>
2853+
<xsl:if test="//MediaObject[@Id=$cmobid]/MediaItem[@Purpose=$curPurpose]/PreviewPic/@File != ''">
2854+
<xsl:attribute name="poster"><xsl:value-of select="$webspace_path"/>mobs/mm_<xsl:value-of select="substring-after($cmobid,'mob_')"/>/<xsl:value-of select="//MediaObject[@Id=$cmobid]/MediaItem[@Purpose=$curPurpose]/PreviewPic/@File"/></xsl:attribute>
2855+
</xsl:if>
28532856
<xsl:if test="$mode != 'edit' and
28542857
(../MediaAliasItem[@Purpose = $curPurpose]/Parameter[@Name = 'autostart']/@Value = 'true' or
28552858
( not(../MediaAliasItem[@Purpose = $curPurpose]/Parameter) and

Services/MediaObjects/Service/class.InternalGUIService.php

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of ILIAS, a powerful learning management system
75
* published by ILIAS open source e-Learning e.V.
@@ -18,6 +16,8 @@
1816
*
1917
*********************************************************************/
2018

19+
declare(strict_types=1);
20+
2121
namespace ILIAS\MediaObjects;
2222

2323
use ILIAS\DI\Container;
@@ -43,6 +43,14 @@ public function __construct(
4343
$this->initGUIServices($DIC);
4444
}
4545

46+
public function standardRequest(): StandardGUIRequest
47+
{
48+
return new StandardGUIRequest(
49+
$this->http(),
50+
$this->domain_service->refinery()
51+
);
52+
}
53+
4654
public function imageMap(): ImageMap\GUIService
4755
{
4856
return new ImageMap\GUIService(
@@ -74,4 +82,12 @@ public function player(): Player\GUIService
7482
$this
7583
);
7684
}
85+
86+
public function video(): Video\GUIService
87+
{
88+
return new Video\GUIService(
89+
$this->domain_service,
90+
$this
91+
);
92+
}
7793
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\MediaObjects;
22+
23+
use ILIAS\Repository\BaseGUIRequest;
24+
25+
class StandardGUIRequest
26+
{
27+
use BaseGUIRequest;
28+
29+
public function __construct(
30+
\ILIAS\HTTP\Services $http,
31+
\ILIAS\Refinery\Factory $refinery,
32+
?array $passed_query_params = null,
33+
?array $passed_post_data = null
34+
) {
35+
$this->initRequest(
36+
$http,
37+
$refinery,
38+
$passed_query_params,
39+
$passed_post_data
40+
);
41+
}
42+
43+
public function getSeconds(): int
44+
{
45+
return $this->int("sec");
46+
}
47+
}

0 commit comments

Comments
 (0)