-
Notifications
You must be signed in to change notification settings - Fork 19
/
islandora_videojs.module
97 lines (91 loc) · 3.32 KB
/
islandora_videojs.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* @file
* An Islandora viewer module using Video.js
*/
/**
* Implements hook_islandora_viewer_info().
*/
function islandora_videojs_islandora_viewer_info() {
return array(
'islandora_videojs' => array(
'label' => t('video.js player'),
'description' => t('video.js for audio and/or video.'),
'callback' => 'islandora_videojs_callback',
'mimetype' => array('audio/mpeg', 'video/mp4'),
'configuration' => 'admin/islandora/islandora_viewers/videojs',
),
);
}
/**
* Implements hook_menu().
*/
function islandora_videojs_menu() {
return array(
'admin/islandora/islandora_viewers/videojs' => array(
'title' => 'Video.js',
'description' => 'Configure the Video.js viewer.',
'page callback' => 'drupal_get_form',
'access arguments' => array('administer site configuration'),
'page arguments' => array('islandora_videojs_admin'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
),
);
}
/**
* Implements hook_theme().
*/
function islandora_videojs_theme($existing, $type, $theme, $path) {
return array(
'islandora_videojs' => array(
'template' => 'theme/islandora-videojs',
'variables' => array('object' => NULL, 'params' => NULL),
),
);
}
/**
* Implements template_preprocess_HOOK().
*/
function template_preprocess_islandora_videojs(array &$variables) {
$params = $variables['params'];
$variables['sources'] = array();
if (isset($params['tn'])) {
$variables['tn'] = $params['tn'];
}
$videojs_path = libraries_get_path("video-js");
drupal_add_js($videojs_path . "/video.js");
drupal_add_css($videojs_path . '/video-js.css');
if (variable_get('islandora_videojs_hls_library', FALSE)) {
drupal_add_js($videojs_path . "/videojs-contrib-hls.js");
}
if (isset($params['sources']) && is_array($params['sources'])) {
$variables['sources'] = $params['sources'];
}
elseif (isset($params['url']) && isset($params['mime'])) {
$variables['sources'][] = array('url' => $params['url'], 'mime' => $params['mime']);
}
$variables['center_play_button'] = variable_get('islandora_videojs_center_play_button', FALSE);
$variables['responsive'] = variable_get('islandora_videojs_responsive', FALSE);
if (variable_get('islandora_videojs_responsive', TRUE)) {
drupal_add_css(drupal_get_path('module', 'islandora_videojs') . '/css/videojs_responsive.css', array('group' => CSS_DEFAULT, 'every_page' => FALSE));
}
$object = islandora_object_load($variables['params']['pid']);
$variables['transcript'] = FALSE;
$transcript_dsid = variable_get('islandora_videojs_transcript_dsid', 'TRANSCRIPT');
if ($object[$transcript_dsid] && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$transcript_dsid])) {
$variables['transcript'] = TRUE;
$variables['transcript_path'] = url("islandora/object/{$object->id}/datastream/{$transcript_dsid}/view");
preg_match('/Language: (.*)/', $object[$transcript_dsid]->content, $matches);
$variables['transcript_language'] = (!empty($matches) ? check_plain($matches[1]) : "English");
}
}
/**
* Callback function to process audio player.
*
* @param array $params
* Array with configuration info for the audio player.
*/
function islandora_videojs_callback($params = array()) {
return theme('islandora_videojs', array('params' => $params));
}