Skip to content

Commit 9070944

Browse files
committed
refactor codes in preparing media player
1 parent 8455128 commit 9070944

File tree

3 files changed

+23
-40
lines changed

3 files changed

+23
-40
lines changed

theme/islandora-html5-video-side.tpl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="col-sm-6 col-md-6">
33
<div data-transcripts-role="video" data-transcripts-id="<?php print $params['trid']; ?>">
44
<div align="center" class="embed-responsive embed-responsive-4by3">
5-
<video class="video-js vjs-default-skin embed-responsive-item" controls preload="auto" width="100%" height="360" data-setup="{}">
5+
<video class="video-js vjs-default-skin embed-responsive-item" controls poster="<?php print $params['tn']; ?>" preload="auto" width="100%" height="360" data-setup="{}">
66
<source src="<?php print $params['url']; ?>" type="<?php print $params['mime']; ?>"/>
77
<?php if (isset($params['tracks']) && $params['enable_transcript_display']): ?>
88
<?php foreach ($params['tracks'] as $key => $track): ?>

theme/islandora-html5-video-stack.tpl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="col-sm-12 col-md-12">
33
<div data-transcripts-role="video" data-transcripts-id="<?php print $params['trid']; ?>">
44
<div align="center" class="embed-responsive embed-responsive-16by9">
5-
<video class="video-js vjs-default-skin embed-responsive-item" controls preload="auto" width="100%" height="360" data-setup="{}">
5+
<video class="video-js vjs-default-skin embed-responsive-item" controls poster="<?php print $params['tn']; ?>" preload="auto" width="100%" height="360" data-setup="{}">
66
<source src="<?php print $params['url']; ?>" type="<?php print $params['mime']; ?>"/>
77
<?php if (isset($params['tracks']) && $params['enable_transcript_display']): ?>
88
<?php foreach ($params['tracks'] as $key => $track): ?>

theme/theme.inc

+21-38
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,17 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari
5858

5959
// construct $variables['islandora_content'] dynamically.
6060
$variables['islandora_content'] = array();
61-
$viewer_params = array();
6261

6362
// prepare viewer params for media file.
64-
try {
65-
$mime = 'video/mp4';
66-
$viewer_params = array(
67-
'pid' => $object->id,
68-
);
69-
$viewer_params += array(
70-
'media_tag' => 'video',
71-
);
63+
$viewer_params = array();
64+
$viewer_params = array(
65+
'pid' => $object->id,
66+
);
67+
68+
if ($object['OBJ']->mimetype == 'video/mp4') {
7269
if (isset($object['MP4'])) {
7370
$media_dsid = 'MP4';
74-
}
75-
if (!$object['MP4']) {
71+
} else {
7672
if (variable_get('islandora_video_play_obj', true)) {
7773
if ($object['OBJ'] && $object['OBJ']->mimetype == 'video/mp4') {
7874
$max_file_size = ((int) variable_get('islandora_video_max_obj_size', 500)) * 1024 * 1024;
@@ -82,12 +78,24 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari
8278
}
8379
}
8480
}
81+
$viewer_params += array(
82+
'media_tag' => 'video',
83+
);
84+
}
8585

86-
// Video player.
86+
if ($object['OBJ']->mimetype == 'audio/mpeg') {
87+
$media_dsid = 'PROXY_MP3';
88+
$viewer_params += array(
89+
'media_tag' => 'audio',
90+
);
91+
92+
}
93+
94+
try {
8795
if (isset($object[$media_dsid]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$media_dsid])) {
8896
$media_url = url("islandora/object/{$object->id}/datastream/$media_dsid/view", array('absolute' => TRUE));
8997
$viewer_params += array(
90-
'mime' => $mime,
98+
'mime' => $object['OBJ']->mimetype,
9199
'url' => $media_url,
92100
);
93101
}
@@ -96,30 +104,6 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari
96104
drupal_set_message(t('Error retrieving datastream %s %t', array('%s' => $media_dsid, '%t' => $e->getMessage())), 'error', FALSE);
97105
}
98106

99-
try {
100-
if (isset($object['PROXY_MP3']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['PROXY_MP3'])) {
101-
$media_dsid = 'PROXY_MP3';
102-
$mime = 'audio/mpeg';
103-
104-
$viewer_params = array(
105-
'pid' => $object->id,
106-
);
107-
$viewer_params += array(
108-
'media_tag' => 'audio',
109-
);
110-
// Audio player.
111-
if (isset($object[$media_dsid]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$media_dsid])) {
112-
$media_url = url("islandora/object/{$object->id}/datastream/$media_dsid/view", array('absolute' => TRUE));
113-
$viewer_params += array(
114-
'mime' => $mime,
115-
'url' => $media_url,
116-
);
117-
}
118-
}
119-
}
120-
catch (Exception $e) {
121-
drupal_set_message(t('Error retrieving datastream %s %t', array('%s' => $media_dsid, '%t' => $e->getMessage())), 'error', FALSE);
122-
}
123107

124108
// Thumbnail.
125109
if (isset($object['TN']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['TN'])) {
@@ -227,7 +211,6 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari
227211
'delete_own' => islandora_oralhistories_web_annotation_access(array('delete own web annotations'), $object),
228212
'delete_any' => islandora_oralhistories_web_annotation_access(array('delete any web annotations'), $object)
229213
);
230-
dpm($js_settings['permissions'], 'perms');
231214
$js_settings['user'] = array(
232215
'uid' => $user->uid,
233216
'name' => ($user->uid == 0) ? 'anonymous' : $user->name

0 commit comments

Comments
 (0)