Browse Source

audio captions part 2 (#830)

* pulling the text track outside of the audio element so its not hidden
* do not set default in the template, because its an attribute that can be set in the track config
pull/837/head
Eli Zoller 4 years ago committed by GitHub
parent
commit
5bc9d04c0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      modules/islandora_audio/islandora_audio.libraries.yml
  2. 43
      modules/islandora_audio/js/audio.js
  3. 5
      modules/islandora_audio/templates/islandora-file-audio.html.twig

7
modules/islandora_audio/islandora_audio.libraries.yml

@ -0,0 +1,7 @@
audio:
version: 1.x
js:
js/audio.js: {preprocess: false}
dependencies:
- core/drupal
- core/drupalSettings

43
modules/islandora_audio/js/audio.js

@ -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);

5
modules/islandora_audio/templates/islandora-file-audio.html.twig

@ -15,14 +15,17 @@
* @ingroup themeable * @ingroup themeable
*/ */
#} #}
<div id="audioTrack"></div>
<audio {{ attributes }}> <audio {{ attributes }}>
{% for file in files %} {% for file in files %}
<source {{ file.source_attributes }} /> <source {{ file.source_attributes }} />
{% if tracks %} {% if tracks %}
{% for track in tracks %} {% for track in tracks %}
<track {{ track.track_attributes }} <track {{ track.track_attributes }} />
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</audio> </audio>
{{ attach_library('islandora_audio/audio') }}

Loading…
Cancel
Save