@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