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

audio captions part 2 #830

Merged
merged 3 commits into from
Apr 28, 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
7 changes: 7 additions & 0 deletions modules/islandora_audio/islandora_audio.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
audio:
version: 1.x
js:
js/audio.js: {preprocess: false}
dependencies:
- core/drupal
- core/drupalSettings
43 changes: 43 additions & 0 deletions modules/islandora_audio/js/audio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*jslint browser: true*/
/*global Audio, Drupal*/
/**
* @file
* Displays Audio viewer.
*/
(function ($, Drupal) {
'use strict';

/**
* If initialized.
* @type {boolean}
*/
var initialized;
/**
* Unique HTML id.
* @type {string}
*/
var base;

function init(context,settings){
if (!initialized){
initialized = true;
$('audio')[0].textTracks[0].oncuechange = function() {
var currentCue = this.activeCues[0].text;
$('#audioTrack').html(currentCue);
}
}
}
Drupal.Audio = Drupal.Audio || {};

/**
* Initialize the Audio Viewer.
*/
Drupal.behaviors.Audio = {
attach: function (context, settings) {
init(context,settings);
},
detach: function () {
}
};

})(jQuery, Drupal);
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
* @ingroup themeable
*/
#}
<div id="audioTrack"></div>
<audio {{ attributes }}>
{% for file in files %}
<source {{ file.source_attributes }} />
{% if tracks %}
{% for track in tracks %}
<track {{ track.track_attributes }}
<track {{ track.track_attributes }} />
{% endfor %}
{% endif %}
{% endfor %}
</audio>

{{ attach_library('islandora_audio/audio') }}