Fix: Call utterance_end callback on WinRT

This commit is contained in:
Bear-03 2022-07-26 17:29:40 +02:00
parent 4cb7e609e0
commit 507eeff456
No known key found for this signature in database
GPG Key ID: 3D1DC5AFDA57B32E
1 changed files with 16 additions and 3 deletions

View File

@ -114,10 +114,23 @@ impl WinRt {
let utterances_clone = tts.utterances.clone();
tts.player.MediaEnded(&TypedEventHandler::new(
move |player: &Option<MediaPlayer>, _args| {
utterances_clone.lock().unwrap().pop_front(); // Utterance that just ended
let mut utterances = utterances_clone.lock().unwrap();
if let Some(utterance) = utterances_clone.lock().unwrap().front() {
utterance.speak(
let ended_utterance = utterances.pop_front().unwrap();
if let Some(callback) = CALLBACKS
.lock()
.unwrap()
.get_mut(&bid)
.unwrap()
.utterance_end
.as_mut()
{
callback(ended_utterance.id);
}
if let Some(new_utterance) = utterances.front() {
new_utterance.speak(
&synth_clone,
player.as_ref().unwrap(),
CALLBACKS.lock().unwrap().get_mut(&bid).unwrap(),