There isnt much information on http://responsivevoice.org about isPlaying()
.
Here is what I tried which isnt working. I do not get the console.log()
.
setInterval(function(){ // continuously check if the audio is being played
if(responsiveVoice.isPlaying()){
console.log('playing..');
},
100
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://responsivevoice.org/responsivevoice/responsivevoice.js"></script>
<textarea id="text" cols="45" rows="3">Hello, world!</textarea>
<input
onclick="responsiveVoice.speak($('#text').val(),'US English Female');"
type="button"
value="Play"
/>
How do I detect if an audio is playing? Also, is there a way to get callback once the audio is done playing?
Thanks for using ResponsiveVoice!
We've added the function isPlaying() to ResponsiveVoice since v1.3.4 and updated the API documentation.
You can now use:
responsiveVoice.isPlaying()
which works for both native SpeechSynthesis and fallback audio TTS.
You can get it here:
http://code.responsivevoice.org/develop/1.3/responsivevoice.js (points to latest release in 1.3.x cycle)
also to get specific version:
http://code.responsivevoice.org/develop/1.3.4/responsivevoice.js