Skip to content

Commit

Permalink
Add video and track support.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimisgold committed May 14, 2021
1 parent ace8125 commit b64c2ec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
29 changes: 28 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,31 @@ function centerrow_display_featured_exhibit() {
}
$html = apply_filters('exhibit_builder_display_random_featured_exhibit', $html);
return $html;
}
}

function centerrow_output_text_track_file($textFile) {
$kind = metadata($textFile, array('Dublin Core', 'Type'));
$language = metadata($textFile, array('Dublin Core', 'Language'));
$label = metadata($textFile, array('Dublin Core', 'Title'));

if (!$kind) {
$kind = 'subtitles';
}

if (!$language) {
$language = get_html_lang();
}

$trackSrc = html_escape($textFile->getWebPath('original'));

if ($label) {
$labelPart = ' label="' . $label . '"';
} else {
$labelPart = '';
}

$track = '<track kind="' . $kind . '" src="' . $trackSrc . '" srclang="' . $language . '"' . $labelPart . '>';

return $track;
}
?>
7 changes: 7 additions & 0 deletions items/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class="media resource"
<video class="lg-video-object lg-html5" controls preload="none">
<source src="<?php echo file_display_url($visualMediaFile, 'original'); ?>" type="<?php echo $visualMediaFile->mime_type; ?>">
<?php echo __('Your browser does not support HTML5 video.'); ?>
<?php $mediaName = pathinfo($visualMediaFile->original_filename, PATHINFO_FILENAME); ?>
<?php foreach ($otherFiles as $key => $otherFile): ?>
<?php if ($otherFile->original_filename == "$mediaName.vtt"): ?>
<?php echo centerrow_output_text_track_file($otherFile); ?>
<?php unset($otherFiles[$key]); ?>
<?php endif; ?>
<?php endforeach; ?>
</video>
</div>
<div class="media-render">
Expand Down

0 comments on commit b64c2ec

Please sign in to comment.