-
Notifications
You must be signed in to change notification settings - Fork 118
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
#2355 Handle multiple audio tracks on a single audio element #1071
Conversation
Turning captions off in HTML5 player doesn't remove captions from display. This appears to be an issue with the current code e.g. https://sandbox.islandora.ca/islandora/interview-diane-hill |
Ah, I didn't even realize this was a thing because I've been using Firefox which doesn't give a captions select/on-off option for audio. Looks like I should have been using Chrome or Edge when working on the audio captions. |
@kayakr, where can I get a copy of the audio with multiple webVTTs so that I can test this out? |
As for removing the captions when they are turned off; we could modify https://github.com/kayakr/islandora/blob/2.x/modules/islandora_audio/js/audio.js#L53-L63 so that we return when we find a showing text track and then, if none are showing, reset the captions box. E.g.
Granted, this would reset the captions for all audio players on the page (if there are more than one). Unfortunately, I don't see a good way to fix this. |
@seth-shaw-asu The sample files I am working with are part of a project that is not yet live. I grabbed the following files from https://ableplayer.github.io/ableplayer/demos/desc2.html
The markup I have in Islandora is: <audio controls="controls" data-once="islandora_audio_captions">
<source src="/_flysystem/fedora/2025-02/ableplayer-wwa.mp3" type="audio/mpeg">
<track src="/_flysystem/fedora/2025-02/wwa_captions_fr.vtt" srclang="fr" label="(fr)Transcript" kind="subtitles">
<track src="/_flysystem/fedora/2025-02/wwa_captions_en.vtt" srclang="en" label="(en)Transcript" kind="subtitles" default="default">
</audio> |
I just tried this code and it didn't work for me as the event listeners are already in place for cues and will fire after the captions box is cleared. We need to tear down or block the cues. I'm not so familiar with the cue code so will need to dig into it more... |
@seth-shaw-asu It looks like we can't |
@seth-shaw-asu I've added a data attribute as a semaphore to indicate whether a track is showing or not. It works, but it's a bit hacky as the cue events are still firing but are gated by checking the |
I'm excited about this! I documented the current one-track behaviour, and would be happy to [edit the docs] if this goes through. If I understand:
|
Same here. My JS-foo is weak, but we do what we can to get the job done. It works, but I have one nit-pick that it is throwing an error at the beginning of the track play:
If we can catch/avoid that then I'm ready to green-light it. |
let cue = e.detail.find(
(cue) =>
cue !== null &&
currentTime >= cue.start &&
currentTime <= cue.end
); |
@seth-shaw-asu I added that line to suppress null cue warning. There's more hackiness in that showing or hiding captions triggers when the next cue event happens, that may not coincide with the timing of making the change in the UI. Again, a refactor could fix this kind of thing. But this is better than what we had before... Screen.Recording.2025-02-21.at.9.49.09.AM.mov@rosiel See screen recording above. The 'kind' needs to be captions of subtitles. Other kinds like chapters are used differently. The media form track field language selector is based on enabled languages for the Drupal site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's more hackiness in that showing or hiding captions triggers when the next cue event happens, that may not coincide with the timing of making the change in the UI. Again, a refactor could fix this kind of thing. But this is better than what we had before...
Amen. If someone with more JS skill wants to come and refactor it, they are welcome to do so. In the mean-time we'll run with what we have.
GitHub Issue: (link)
#2355 Handle multiple audio tracks
Release pull requests, etc.)
What does this Pull Request do?
Reworks islandora audio js to add a eventListener to detect a track change, to allow the user to switch between multiple webvtt tracks for an audio element (e.g. different webvtt files for different languages).
What's new?
I don't expect this to work for multiple audio elements on the same page. The event listener assumes only one track has the mode='showing'.
It wraps the previous logic in a new function
bindVttSource()
so we can invoke it on different track files.How should this be tested?
Browser should see markup like this:
Documentation Status
Interested parties
@Islandora/committers @seth-shaw-asu