http://responsivevoice.org上关于isPlaying()
的信息不多。
这是我尝试的不起作用的方法。我没有得到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"
/>
如何检测是否正在播放音频?另外,一旦音频播放完毕,是否有办法获取回调?
最佳答案
感谢您使用ResponsiveVoice!
自v1.3.4起,我们已将函数isPlaying()添加到ResponsiveVoice,并更新了API文档。
您现在可以使用:
responsiveVoice.isPlaying()
适用于本机SpeechSynthesis和后备音频TTS。
你可以在这里得到它:
http://code.responsivevoice.org/develop/1.3/responsivevoice.js(指向1.3.x周期的最新版本)
还要获取特定版本:
http://code.responsivevoice.org/develop/1.3.4/responsivevoice.js
关于javascript - 无法检测responseVoice isPlaying(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27885616/