[英]ResponsiveVoice code within SetInterval in Javascript: How to stop the loop?
Currently I'm doing queuing system and I'm working on voice announcing using responsive voice.目前我正在做排队系统,我正在使用响应式语音进行语音播报。 I put it on the setInterval but the problem is it is looping and the voice would never stop.
我把它放在 setInterval 上,但问题是它在循环,声音永远不会停止。
$( document ).ready(function() {
setInterval(function() {
$.ajax({
url: "/getnewdata",
cache: false,
}).done(function(html) {
$( '#data-container' ).html(html);
});
responsiveVoice.speak("{{ $new_call->letter }}-{{ $new_call->number }} please proceed to Counter {{ $new_call->counter_id }}")
}, 3000);
});
I just want that voice announcer would only loop once.我只希望那个语音播音员只循环一次。 Another problem, when the data is newly added, it should announce a data.
另一个问题,当新添加数据时,它应该宣布一个数据。 And another problem is instead of for example "no. 30", it speaks "no. 29".
另一个问题不是例如“30 号”,而是“29 号”。
I try this one我试试这个
$( document ).ready(function() {
setInterval(function() {
$.ajax({
url: "/getnewdata",
cache: false,
}).done(function(html) {
$( '#data-container' ).html(html);
setTimeout(function() {
function voiceStartCallback() {
console.log("Voice started");
}
function voiceEndCallback() {
console.log("Voice ended");
}
var parameters = {
onstart: voiceStartCallback,
onend: voiceEndCallback
}
responsiveVoice.speak("{{ $new_call->letter }}-{{ $new_call->number }} please proceed to Counter {{ $new_call->counter_id }}", parameters)
}, 800);
});
}, 3000);
});
When I look at the console it has an error: Uncaught TypeError: Cannot read property 'deprecated' of null at ResponsiveVoice.a.speak (responsivevoice.js?key=8PNDpxy8:117) at queue:178当我查看控制台时出现错误:Uncaught TypeError: Cannot read property 'deprecated' of null at ResponsiveVoice.a.speak (responsivevoice.js?key=8PNDpxy8:117) at queue:178
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.