@@ -34,6 +34,7 @@ class ilObjMediaCastGUI extends ilObjectGUI
34
34
{
35
35
protected \ILIAS \MediaObjects \MediaType \MediaTypeManager $ media_type ;
36
36
protected \ILIAS \MediaCast \InternalGUIService $ gui ;
37
+ protected $ video_gui ;
37
38
protected \ILIAS \MediaCast \MediaCastManager $ mc_manager ;
38
39
protected ilPropertyFormGUI $ form_gui ;
39
40
protected ilNewsItem $ mcst_item ;
@@ -87,6 +88,7 @@ public function __construct(
87
88
->domain ()->mediaCast ();
88
89
$ this ->gui = $ DIC ->mediaCast ()->internal ()->gui ();
89
90
$ this ->media_type = $ DIC ->mediaObjects ()->internal ()->domain ()->mediaType ();
91
+ $ this ->video_gui = $ DIC ->mediaObjects ()->internal ()->gui ()->video ();
90
92
}
91
93
92
94
public function executeCommand (): void
@@ -389,32 +391,15 @@ public function editCastItemObject(): void
389
391
390
392
$ this ->checkPermission ("write " );
391
393
394
+ $ this ->mcst_item = new ilNewsItem (
395
+ $ this ->mc_request ->getItemId ()
396
+ );
397
+
392
398
// 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
+ );
418
403
419
404
$ this ->initAddCastItemForm ("edit " );
420
405
$ this ->getCastItemValues ($ item_id );
@@ -532,10 +517,12 @@ public function initAddCastItemForm(string $a_mode = "create"): void
532
517
$ this ->form_gui ->addItem ($ ne );
533
518
534
519
// 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 );
539
526
}
540
527
}
541
528
@@ -564,14 +551,6 @@ public function getCastItemValues(int $item_id): void
564
551
);
565
552
$ mob = new ilObjMediaObject ($ this ->mcst_item ->getMobId ());
566
553
567
- // preview
568
- $ ppic = $ mob ->getVideoPreviewPic ();
569
- if ($ ppic != "" ) {
570
- $ i = $ this ->form_gui ->getItemByPostVar ("preview_pic " );
571
- $ i ->setImage ($ ppic );
572
- }
573
-
574
-
575
554
$ values = array ();
576
555
$ mediaItems = $ this ->getMediaItems (
577
556
$ this ->mc_request ->getItemId ()
@@ -635,10 +614,7 @@ public function saveCastItemObject(): void
635
614
$ mob ->setDescription ($ description );
636
615
637
616
// 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 ());
642
618
643
619
// determine duration for standard purpose
644
620
$ duration = $ this ->getDuration ($ file );
@@ -856,15 +832,7 @@ public function updateCastItemObject(): void
856
832
$ mob ->setTitle ($ title );
857
833
$ mob ->setDescription ($ description );
858
834
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 ());
868
836
}
869
837
}
870
838
@@ -1666,35 +1634,11 @@ public function showGallery(): void
1666
1634
public function extractPreviewImageObject (): void
1667
1635
{
1668
1636
$ ilCtrl = $ this ->ctrl ;
1669
- $ add = "" ;
1670
-
1671
1637
$ this ->checkPermission ("write " );
1672
-
1673
1638
$ 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
+ );
1698
1642
$ ilCtrl ->redirect ($ this , "editCastItem " );
1699
1643
}
1700
1644
0 commit comments