From e1c217183350075d2c0f17c09ce15cfcbfc50fde Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 30 Dec 2020 09:49:13 -0600 Subject: [PATCH] Support stopping. --- src/backends/android.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/backends/android.rs b/src/backends/android.rs index 577a3a4..6cf59aa 100644 --- a/src/backends/android.rs +++ b/src/backends/android.rs @@ -107,7 +107,7 @@ impl Backend for Android { fn supported_features(&self) -> Features { Features { - stop: false, + stop: true, rate: false, pitch: false, volume: false, @@ -148,7 +148,16 @@ impl Backend for Android { } fn stop(&mut self) -> Result<(), Error> { - todo!() + let vm = Self::vm()?; + let env = vm.get_env()?; + let tts = self.tts.as_obj(); + let rv = env.call_method(tts, "stop", "()I", &[])?; + let rv = rv.i()? as i32; + if rv == 0 { + Ok(()) + } else { + Err(Error::OperationFailed) + } } fn min_rate(&self) -> f32 {