0 votes
in SoSci Survey (English) by s095200 (195 points)

I have embedded an audio file within the text element. As a consequence, the audiofile of the question below it does not work anymore. Why is that? Here is my code in the text:

<style>
#playButton {
  border-radius: 2px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  padding: 3px 12px;
}
</style>

.... some text...

<audio id="audioPlayer" preload="auto" controlsList="nodownload">
  <source src="pro://second_pfu_2_d.flac" type="audio/mpeg" />
  Il tuo browser non può riprodurre questo file audio. Prova ad aprire il questionario con un altro browser. Se il file continua a non essere riprodotto, abbandona l'esperimento
</audio>
<button id="playButton" type="button">▶</button>
<script type="text/javascript">
<!--
  var audioPlayer = document.getElementById('audioPlayer');
  var playButton = document.getElementById('playButton');
  var playbackCounter = 0;
  var currentlyPlaying = false;
  
  SoSciTools.attachEvent(playButton, "click", playAudio);
  SoSciTools.attachEvent(audioPlayer, "ended", audioEnded);  
  
  function playAudio() {
	  if(!currentlyPlaying) {
		audioPlayer.play();
		currentlyPlaying = true;
		playbackCounter++;
                document.getElementById("C311_01").value = playbackCounter;
	  }
  }
  
  function audioEnded() {
	currentlyPlaying = false;
  }
-->
</script> 

... some text

1 Answer

0 votes
by SoSci Survey (302k points)

The standards say that <style> elements should be placed in the <head>, not in the content. You can do that with pageCSS(). Most browsers will still accept the incorrect placement.

the audiofile of the question below it does not work anymore.

The most likely explanation ... not knowing the HTML code of the second audiofile ... is that you use the same HTML ID "playButton" for both buttons. This could effectively disable one of the buttons, because only one is addresses by the JavaScript.

If you need a more concise answer, please post a pretest link directly (!) to the questionnaire page with the problem.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...