Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.26.1+210427
Own server or LimeSurvey hosting: Hosted by educational institution
Survey theme/template:
==================
Hi there,
As part of a regular single-choice question, I would like users to be able to play an embedded audio file, which they then answer a question about.
I have managed to embed the file using this code:
Code:
<p>In the following recording, is the word <strong>putting </strong>pronounced as <strong>putt<u>ing</u> </strong>[ɪŋ] or as <strong>putt<u>in'</u></strong> [ɪn]?</p>
<p style="text-align: left;">
<audio controls="controls"><source src="/upload/surveys/184592/files/michaela_ING_orig_sent_1_final.wav" type="audio/mp3" /></audio>
</p>
However, I would to like to adapt it so that participants can start the audio but can neither pause nor replay it. So, an autoplay solution would not be my preference.
I have found this snippet of code (taken from:
Link
), which creates a seperate button and a counter that reduces the number of replays every time a user has listened to the audio in full. The code is written for video files and I have only tried it with MP4 so far. Ultimately, I need code that lets me embed audio though.
Inserted before the actual vid element, whose code has been slightly modified by adding
Code:
id="Mimmi" and by deleting the controls= snippet.
Code:
<button id="counter" onclick="document.getElementById('Mimmi').play(); return false;" style="border: solid black 1px"> </button>
<script>
let vidcount = 3; // CHANGE THIS NUMBER AS NEEDED
$(document).ready(function() {
document.getElementById("counter").innerHTML = "Click. "+vidcount+" times left.";
var vid = document.getElementById("Mimmi");
vid.onEnded = function() {
vidcount = vidcount-1;
if (vidcount > 0) {
document.getElementById("counter").innerHTML = vidcount+" times left.";
} else {
$('#ls-button-submit').show().trigger('click');
}
}
});
</script>
Unfortunately, while the button is created and the controls are hidden, the counter doesn't seem to work: the number of remaining replays is not reduced and participants could basically still replay the file as often as they like.
I am completely new to javascript, so I am pretty lost when it comes to debugging the code or adapting it to my use case (i.e. embedding audio instead of video files).
Is there anything wrong with the code? Is there a fix?
Any help would be much appreciated! Thanks a lot!
Jana