SpeechSynthesis onpause onresume不会触发

时间:2016-01-19 12:46:40

标签: javascript speech-synthesis

以下代码适用于onstart和onend,但不适用于声音,暂停,onresume或手动speechSynthesis.paused间隔。为什么呢?

浏览器:Chrome版本47.0.2526.111 m

http://jsfiddle.net/QYw6b/89/

或:

var u = new SpeechSynthesisUtterance();
var voices = speechSynthesis.getVoices();
u.voice = voices[0];
console.log(voices);
u.text = 'Hello World';

u.onstart = function (event) {
    console.log('Started');
};
u.onend = function (event) {
    console.log('Ended');
};

u.onpause = function(event) {
    console.log('Paused');
};
u.onresume = function(event) {
    console.log('Resumed');
};

setInterval(function() {
    if(speechSynthesis.paused)
        console.log("Now it's paused");}
,100);


setTimeout(function(){speechSynthesis.speak(u);},2000);
setTimeout(function(){speechSynthesis.pause();},3000);
setTimeout(function(){speechSynthesis.resume();},6000);
console.log(u);

0 个答案:

没有答案