]> _ Git - odl.git/commitdiff
wip #4914 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 4 Jan 2022 10:30:12 +0000 (11:30 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 4 Jan 2022 10:30:12 +0000 (11:30 +0100)
composer.json
resources/views/components/media-library/index.blade.php
resources/views/components/media-library/player.blade.php
resources/views/front/media-library.blade.php

index b572211b8971c3730ea5b398c698ce38b15e593a..973b85bd884d22d5f55e64f724b530130a520be0 100644 (file)
@@ -30,6 +30,7 @@
         "laravel/sanctum": "^2.11",
         "laravel/tinker": "^2.6",
         "mxl/laravel-job": "^1.2",
+        "php-ffmpeg/php-ffmpeg": "^0.19.0",
         "predis/predis": "^1.1"
     },
     "require-dev": {
index cfaac42b378b7bc73298e4a578daad1f0e0cee67..8c4697502f0a3134b68898f2c47b28986fa2c91c 100644 (file)
@@ -57,7 +57,7 @@
                         media-{{ $item['type'] }}
                         theme-{{ $item['theme'] }}"
             >
-                <div class="media-item-image relative bg-cover bg-no-repeat rounded-md pb-[56.25%]" style="background-image:url({{ $item['image'] }})">
+                <div class="media-item-image relative bg-cover bg-no-repeat rounded-md pb-[56.25%]" style="background-color:#ddd;background-image:url({{ $item['image'] }})">
 
                     {{-- Play Icon --}}
                     <svg class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 transition group-hover:scale-110"
index 74af5e5e218bbaccd0c9546e657d3b80fa5112a8..fade53d8e8d6cbd2091f7b7327fb6248da22684a 100644 (file)
@@ -46,7 +46,7 @@
             {{-- Player Image / Poster --}}
             <div x-show="playerType === 'audio'"
                  class="rounded-md bg-cover bg-center flex-shrink-0 mr-10"
-                 :style="`width:200px; height:200px; background-image:url(${playerImage})`"></div>
+                 :style="`width:200px; height:200px; background-color:#ddd; background-image:url(${playerImage})`"></div>
 
             <div class="w-full">
 
index c3f4a9884ae1e464b6fa1424b283b4e7cbea7d60..25e1d09fb7b810ca805636826e4746de370050fd 100644 (file)
@@ -5,94 +5,6 @@
     @php
 
 
-        // TEMPORARY DATA MOCKUP
-        $media = [
-            [
-                'id' => 123,
-                'title' => "Qu’est ce que la gouvernance ?",
-                'type' => 'video',
-                'duration' => '78',
-                'image' => '/storage/46/conversions/VIDEO2-poster.jpg',
-                'file' => '/storage/46/VIDEO2.mov',
-                'mime_type' => 'video/mp4',
-                'theme' => [
-                    'id' => 1,
-                    'title' => 'Gouvernance',
-                    'color' => '#FA4E66',
-                ],
-            ],
-            [
-                'id' => 545,
-                'title' => 'Les outils de communication',
-                'type' => 'video',
-                'duration' => '192',
-                'image' => '/storage/4/conversions/Big-rock-at-the-beach-poster.jpg',
-                'file' => '/storage/4/Big-rock-at-the-beach.mp4',
-                'mime_type' => 'video/mp4',
-                'theme' => [
-                    'id' => 2,
-                    'title' => 'Communication',
-                    'color' => '#FBB100',
-                ],
-            ],
-            [
-                'id' => 785,
-                'title' => "Une organisation à plusieurs niveaux",
-                'type' => 'audio',
-                'duration' => '144',
-                'image' => '/storage/126/wp280699-turtle-wallpaper.jpg',
-                'file' => '/storage/83/hs1mp3.mp3',
-                'mime_type' => 'audio/mpeg',
-                'theme' => [
-                    'id' => 3,
-                    'title' => 'Organisation',
-                    'color' => '#7A2AA1',
-                ],
-            ],
-            [
-                'id' => 65,
-                'title' => 'Système d’information',
-                'type' => 'audio',
-                'duration' => '987',
-                'image' => '/storage/4/conversions/Big-rock-at-the-beach-poster.jpg',
-                'file' => '/storage/83/hs1mp3.mp3',
-                'mime_type' => 'audio/mpeg',
-                'theme' => [
-                    'id' => 4,
-                    'title' => 'Système d’information',
-                    'color' => '#2AB3C9',
-                ],
-            ],
-            [
-                'id' => 146,
-                'title' => "Qu’est ce que la gouvernance ?",
-                'type' => 'video',
-                'duration' => '614',
-                'image' => '/storage/46/conversions/VIDEO2-poster.jpg',
-                'file' => '/storage/46/VIDEO2.mov',
-                'mime_type' => 'video/mp4',
-                'theme' => [
-                    'id' => 1,
-                    'title' => 'Gouvernance',
-                    'color' => '#FA4E66',
-                ],
-            ],
-            [
-                'id' => 370,
-                'title' => 'Les outils de communication',
-                'type' => 'audio',
-                'duration' => '45',
-                'image' => '/storage/125/victor-ene-cmrp-0mg8f0-unsplash.jpg',
-                'file' => '/storage/83/hs1mp3.mp3',
-                'mime_type' => 'audio/mpeg',
-                'theme' => [
-                    'id' => 2,
-                    'title' => 'Communication',
-                    'color' => '#FBB100',
-                ],
-            ],
-        ];
-
         $media_types = [
             'video' => 'Vidéos',
             'audio' => 'Podcast',
         }
 
         $media=[];
+        $ffprobe = FFMpeg\FFProbe::create();
+        foreach ($medialibrary['assets'] as $a) {
+            /** @var $a \Cubist\Backpack\Magic\PageData */
+            $file=$a->getMediaPathsByCollection($a->get('file_upload'))[0]??null;
+            if(null===$file){
+                continue;
+            }
 
+            $spf=new SplFileInfo($file);
+            $ext=mb_strtolower($spf->getExtension());
+            $map=['mp3'=>'audio','mp4'=>'video'];
+            $type=$map[$ext]??$a->get('type');
 
-        foreach ($medialibrary['assets'] as $a) {
             $media[$a['id']]=[
                 'id'=>$a->get('id'),
-                'type'=>$a->get('type'),
+                'type'=>$type,
                 'theme'=>$a->get('theme'),
                 'title'=>$a->get('title'),
                 'file'=>$a->getImageURLbyCollection($a->get('file_upload')),
-                'image'=>$a->getImageURLbyCollection($a->get('file_thumb')),
-                'duration'=>45,
+                'image'=>$a->getImageURLbyCollection($a->get('file_thumb'))??$a->getImageURLbyCollection($a->get('file_upload'),'poster'),
+                'duration'=>$ffprobe->format($file)->get('duration')
                ];
         }
     @endphp