Skip to content

Commit

Permalink
refactor codes in preparing media player
Browse files Browse the repository at this point in the history
  • Loading branch information
sprklinginfo committed Jan 7, 2016
1 parent 8455128 commit 9070944
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 40 deletions.
2 changes: 1 addition & 1 deletion theme/islandora-html5-video-side.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="col-sm-6 col-md-6">
<div data-transcripts-role="video" data-transcripts-id="<?php print $params['trid']; ?>">
<div align="center" class="embed-responsive embed-responsive-4by3">
<video class="video-js vjs-default-skin embed-responsive-item" controls preload="auto" width="100%" height="360" data-setup="{}">
<video class="video-js vjs-default-skin embed-responsive-item" controls poster="<?php print $params['tn']; ?>" preload="auto" width="100%" height="360" data-setup="{}">
<source src="<?php print $params['url']; ?>" type="<?php print $params['mime']; ?>"/>
<?php if (isset($params['tracks']) && $params['enable_transcript_display']): ?>
<?php foreach ($params['tracks'] as $key => $track): ?>
Expand Down
2 changes: 1 addition & 1 deletion theme/islandora-html5-video-stack.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="col-sm-12 col-md-12">
<div data-transcripts-role="video" data-transcripts-id="<?php print $params['trid']; ?>">
<div align="center" class="embed-responsive embed-responsive-16by9">
<video class="video-js vjs-default-skin embed-responsive-item" controls preload="auto" width="100%" height="360" data-setup="{}">
<video class="video-js vjs-default-skin embed-responsive-item" controls poster="<?php print $params['tn']; ?>" preload="auto" width="100%" height="360" data-setup="{}">
<source src="<?php print $params['url']; ?>" type="<?php print $params['mime']; ?>"/>
<?php if (isset($params['tracks']) && $params['enable_transcript_display']): ?>
<?php foreach ($params['tracks'] as $key => $track): ?>
Expand Down
59 changes: 21 additions & 38 deletions theme/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,17 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari

// construct $variables['islandora_content'] dynamically.
$variables['islandora_content'] = array();
$viewer_params = array();

// prepare viewer params for media file.
try {
$mime = 'video/mp4';
$viewer_params = array(
'pid' => $object->id,
);
$viewer_params += array(
'media_tag' => 'video',
);
$viewer_params = array();
$viewer_params = array(
'pid' => $object->id,
);

if ($object['OBJ']->mimetype == 'video/mp4') {
if (isset($object['MP4'])) {
$media_dsid = 'MP4';
}
if (!$object['MP4']) {
} else {
if (variable_get('islandora_video_play_obj', true)) {
if ($object['OBJ'] && $object['OBJ']->mimetype == 'video/mp4') {
$max_file_size = ((int) variable_get('islandora_video_max_obj_size', 500)) * 1024 * 1024;
Expand All @@ -82,12 +78,24 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari
}
}
}
$viewer_params += array(
'media_tag' => 'video',
);
}

// Video player.
if ($object['OBJ']->mimetype == 'audio/mpeg') {
$media_dsid = 'PROXY_MP3';
$viewer_params += array(
'media_tag' => 'audio',
);

}

try {
if (isset($object[$media_dsid]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$media_dsid])) {
$media_url = url("islandora/object/{$object->id}/datastream/$media_dsid/view", array('absolute' => TRUE));
$viewer_params += array(
'mime' => $mime,
'mime' => $object['OBJ']->mimetype,
'url' => $media_url,
);
}
Expand All @@ -96,30 +104,6 @@ function islandora_oralhistories_preprocess_islandora_oralhistories(array &$vari
drupal_set_message(t('Error retrieving datastream %s %t', array('%s' => $media_dsid, '%t' => $e->getMessage())), 'error', FALSE);
}

try {
if (isset($object['PROXY_MP3']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['PROXY_MP3'])) {
$media_dsid = 'PROXY_MP3';
$mime = 'audio/mpeg';

$viewer_params = array(
'pid' => $object->id,
);
$viewer_params += array(
'media_tag' => 'audio',
);
// Audio player.
if (isset($object[$media_dsid]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$media_dsid])) {
$media_url = url("islandora/object/{$object->id}/datastream/$media_dsid/view", array('absolute' => TRUE));
$viewer_params += array(
'mime' => $mime,
'url' => $media_url,
);
}
}
}
catch (Exception $e) {
drupal_set_message(t('Error retrieving datastream %s %t', array('%s' => $media_dsid, '%t' => $e->getMessage())), 'error', FALSE);
}

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

0 comments on commit 9070944

Please sign in to comment.