Skip to content

Commit

Permalink
Merge pull request #47 from aynsix/PHRAS-2884-clean-chapter-config-name
Browse files Browse the repository at this point in the history
PHRAS-2884: #comment merge in embed-bundle Semantic clean for Chapter Vtt source
  • Loading branch information
nmaillat authored Feb 4, 2020
2 parents cbaa5e3 + b43a10a commit 8cdb961
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/Component/Media/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,27 @@ public function getAvailableVideoTextTracks(MediaInformation $media)
$vttIds = [];
$vttMetadata = [];

$chapterVttFieldName = 'VideoTextTrackChapters'; // as default name if configuration is not set up

if (array_key_exists('ChapterVttFieldName', $this->app['phraseanet.configuration']['video-editor'])) {
$chapterVttFieldName = $this->app['phraseanet.configuration']['video-editor']['ChapterVttFieldName'];
}

// extract vtt ids and labels
foreach ($databox->get_meta_structure() as $meta) {
$foundParts = [];
if (preg_match('/^VideoTextTrack(.*)$/iu', $meta->get_name(), $foundParts)) {

if ($meta->get_name() === $chapterVttFieldName ) {
$vttIds[] = $meta->get_id();

$vttMetadata[$meta->get_id()] = [
'label' => 'chapters', //@todo translate
'srclang' => '',
'default' => true,
'kind' => 'chapters',
];

} elseif (preg_match('/^VideoTextTrack(.*)$/iu', $meta->get_name(), $foundParts)) {
$vttIds[] = $meta->get_id();

/*
Expand All @@ -284,23 +301,12 @@ public function getAvailableVideoTextTracks(MediaInformation $media)
- metadata
- subtitles
*/
$kind = '';
$setAsDefault = false;
$vttFoundKind = strtolower($foundParts[1]);
switch ($vttFoundKind) {
case 'chapters':
$setAsDefault = true;
$kind = 'chapters';
break;
default:
$kind = 'subtitles';
}


$vttMetadata[$meta->get_id()] = [
'label' => empty($foundParts[1]) ? 'default' : $foundParts[1], //@todo translate
'label' => empty($foundParts[1]) ? 'default' : $foundParts[1], //@todo translate
'srclang' => '',
'default' => $setAsDefault,
'kind' => $kind,
'default' => false,
'kind' => 'subtitles',
];
}
}
Expand Down

0 comments on commit 8cdb961

Please sign in to comment.