Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subtitle/transcript capability #53

Merged
merged 5 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ For example, at **Administration » Islandora » Solution pack configuration »
![Solution Pack Configuration](https://user-images.githubusercontent.com/2738244/40234143-b0c31ea6-5a73-11e8-9e3b-8133917d496c.png)

Configure Video.js at **Administration » Islandora » Islandora Viewers » Video.js** (_admin/islandora/islandora_viewers/videojs_).
Three options are available:
Four options are available:

* "Videojs-contrib-hls library" to enable HTTP Live Streaming (a streaming format native to mobile phones).
* "Center play button" to put the play button in the center of the player, rather than the top left corner.
* "Responsive player" to make the Video.js player responsive but requires you use a responsive theme.
* "Transcript/Subtitle DSID" sets the datastream ID containing a WebVTT transcript.

To use transcripts, on the object in question, add a custom datastream using the configured DSID (default TRANSCRIPT) and upload a WebVTT file.

![Configuration](https://user-images.githubusercontent.com/1943338/32968854-2575fc40-cbb9-11e7-9e85-66fec561a24c.png)

Expand Down
7 changes: 6 additions & 1 deletion includes/admin.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function islandora_videojs_admin($form, &$form_state) {
'#description' => t('Make the videojs player responsive (requires a responsive theme)'),
'#default_value' => variable_get('islandora_videojs_responsive', FALSE),
);

$form['islandora_videojs_transcript_dsid'] = array(
'#type' => 'textfield',
'#title' => t('Transcript/Subtitle DSID'),
'#description' => t('Datastream ID used for transcript/subtitle datastreams.'),
'#default_value' => variable_get('islandora_videojs_transcript_dsid', 'TRANSCRIPT'),
);
return system_settings_form($form);
}

Expand Down
1 change: 1 addition & 0 deletions islandora_videojs.install
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function islandora_videojs_uninstall() {
'islandora_videojs_hls_library',
'islandora_videojs_center_play_button',
'islandora_videojs_responsive',
'islandora_videojs_transcript_dsid',
);
array_walk($variables, 'variable_del');
}
9 changes: 9 additions & 0 deletions islandora_videojs.module
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ function template_preprocess_islandora_videojs(array &$variables) {
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']);
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
$variables['transcript'] = FALSE;
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
$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);
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
$variables['transcript_language'] = (!empty($matches) ? check_plain($matches[1]) : "English");
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions theme/islandora-videojs.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<?php foreach ($sources as $source): ?>
<source src="<?php print $source['url']; ?>" type='<?php print $source['mime']; ?>'>
<?php endforeach; ?>
<?php if ($transcript): ?>
<track kind="captions" src="<?php print $transcript_path; ?>" label="<?php print $transcript_language; ?>" default>
adam-vessey marked this conversation as resolved.
Show resolved Hide resolved
<?php endif; ?>
</video>
<?php if (empty($sources)): ?>
<div id="video-js-warning">
Expand Down