Skip to content

Commit

Permalink
Merge remote-tracking branch 'yzen/demo' into demo
Browse files Browse the repository at this point in the history
* yzen/demo:
  FLUID-4947: added some fixes to text split and error handling.
  • Loading branch information
michelled committed Apr 1, 2013
2 parents 2b96d0f + f8c1f4a commit 3df820c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/webapp/integration-demos/uiOptions/js/SelfVoicingEnactor.js
Expand Up @@ -69,7 +69,7 @@ var fluid_1_5 = fluid_1_5 || {};
queue: []
},
strings: {
loaded: "Text to Speech Enabled"
loaded: "text to speech enabled"
},
styles: {
current: "fl-selfVoicing-current"
Expand Down Expand Up @@ -97,12 +97,18 @@ var fluid_1_5 = fluid_1_5 || {};
$("body").remove(that.options.audioSelector);
$("body").append(that.audio);
var audioElement = that.audio[0];
audioElement.addEventListener("loadedmetadata", function () {
audioElement.addEventListener("canplaythrough", function () {
if (!that.model.value) {
return;
}
audioElement.play();
setTimeout(that.events.afterAnnounce.fire, audioElement.duration * 1000);
setTimeout(that.events.afterAnnounce.fire, audioElement.duration * 1000 + 500);
});
audioElement.addEventListener("error", function () {
if (!that.model.value) {
return;
}
setTimeout(that.events.afterAnnounce.fire, 1500);
});
};

Expand Down Expand Up @@ -134,7 +140,7 @@ var fluid_1_5 = fluid_1_5 || {};
return;
}
var currentText = text.substr(0, 100);
var sIndex = currentText.lastIndexOf("\s");
var sIndex = currentText.lastIndexOf(" ");
queue.push(currentText.substring(0, sIndex));
buildSpeechQueueImpl(queue, text.substring(sIndex + 1));
};
Expand Down

0 comments on commit 3df820c

Please sign in to comment.