From e0194163a812569784a72706cc199e0ae741bc24 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 4 Jan 2022 11:30:12 +0100 Subject: [PATCH] wip #4914 @0.75 --- composer.json | 1 + .../components/media-library/index.blade.php | 2 +- .../components/media-library/player.blade.php | 2 +- resources/views/front/media-library.blade.php | 106 +++--------------- 4 files changed, 17 insertions(+), 94 deletions(-) diff --git a/composer.json b/composer.json index b572211..973b85b 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/resources/views/components/media-library/index.blade.php b/resources/views/components/media-library/index.blade.php index cfaac42..8c46975 100644 --- a/resources/views/components/media-library/index.blade.php +++ b/resources/views/components/media-library/index.blade.php @@ -57,7 +57,7 @@ media-{{ $item['type'] }} theme-{{ $item['theme'] }}" > -
+
{{-- Play Icon --}}
+ :style="`width:200px; height:200px; background-color:#ddd; background-image:url(${playerImage})`">
diff --git a/resources/views/front/media-library.blade.php b/resources/views/front/media-library.blade.php index c3f4a98..25e1d09 100644 --- a/resources/views/front/media-library.blade.php +++ b/resources/views/front/media-library.blade.php @@ -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', @@ -108,17 +20,27 @@ } $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 -- 2.39.5