mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-23 03:39:38 +00:00
Implement stop callback on MacOS.
This commit is contained in:
parent
8c783205c3
commit
6f12974ce4
|
@ -66,6 +66,24 @@ impl AvFoundation {
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" fn speech_synthesizer_did_cancel_speech_utterance(
|
||||
this: &Object,
|
||||
_: Sel,
|
||||
_synth: *const Object,
|
||||
utterance: id,
|
||||
) {
|
||||
unsafe {
|
||||
let backend_id: u64 = *this.get_ivar("backend_id");
|
||||
let backend_id = BackendId::AvFoundation(backend_id);
|
||||
let mut callbacks = CALLBACKS.lock().unwrap();
|
||||
let callbacks = callbacks.get_mut(&backend_id).unwrap();
|
||||
if let Some(callback) = callbacks.utterance_stop.as_mut() {
|
||||
let utterance_id = UtteranceId::AvFoundation(utterance);
|
||||
callback(utterance_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
decl.add_method(
|
||||
sel!(speechSynthesizer:didStartSpeechUtterance:),
|
||||
|
@ -77,6 +95,11 @@ impl AvFoundation {
|
|||
speech_synthesizer_did_finish_speech_utterance
|
||||
as extern "C" fn(&Object, Sel, *const Object, id) -> (),
|
||||
);
|
||||
decl.add_method(
|
||||
sel!(speechSynthesizer:didCancelSpeechUtterance:),
|
||||
speech_synthesizer_did_cancel_speech_utterance
|
||||
as extern "C" fn(&Object, Sel, *const Object, id) -> (),
|
||||
);
|
||||
}
|
||||
|
||||
let delegate_class = decl.register();
|
||||
|
|
Loading…
Reference in New Issue
Block a user