-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathislandora_interview.module
52 lines (43 loc) · 1.4 KB
/
islandora_interview.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
use \Drupal\Core\Url;
/**
* Implements hook_theme().
*/
function islandora_interview_theme() {
return [
'media__islandora_rdm_interview__teaser' => [
'template' => 'media--islandora-rdm-interview--teaser',
'preprocess functions' => ['islandora_rdm_interview_preprocess'],
'base hook' => 'media',
],
];
}
function islandora_interview_preprocess_media__islandora_rdm_interview__teaser(&$variables) {
# ksm($variables);
$media = $variables['media'];
$items = [];
$captions = [];
$recording_field = $media->get('field_interview_compressed_audio')->entity;
if (!empty($recording_field)) {
$items[] = ['src' => file_create_url($recording_field->getFileUri()), 'type' => 'audio/mp3'];
}
$caption_field = $media->get('field_interview_vtt_file')->entity;
if (!empty($caption_field)) {
$captions_item = file_create_url($caption_field->getFileUri());
$captions[] = [
'src' => $captions_item,
'kind' => 'captions',
'srclang' => $media->language,
'label' => 'Captions',
];
}
$variables['interview'] = array(
'#theme' => 'videojs',
'#items' => $items,
'#captions' => $captions,
'#player_attributes' => ['controls' => TRUE, 'width' => 500, 'height' => 400, 'poster' => base_path() . "core/themes/classy/images/icons/audio-x-generic.png"],
'#attached' => array(
'library' => array('videojs/videojs'),
),
);
}