From c82ea5f3b3a2dd5cc32e4c8d3da3baca9288ec78 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 9 Jun 2020 11:00:37 -0500 Subject: [PATCH] WinRT fixes. * Use released `winrt` crate. * Implement `is_speaking`. --- Cargo.toml | 2 +- src/backends/winrt.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 03eaeeb..835a140 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ thiserror = "1" [target.'cfg(windows)'.dependencies] tolk = "0.2" -winrt = { git = "https://github.com/microsoft/winrt-rs", rev = "ed46a71f506c343b3eb4fa6c15a4d9db1397ebcf" } +winrt = "0.7" [target.'cfg(target_os = "linux")'.dependencies] speech-dispatcher = "0.4" diff --git a/src/backends/winrt.rs b/src/backends/winrt.rs index 3e06876..54ffb94 100644 --- a/src/backends/winrt.rs +++ b/src/backends/winrt.rs @@ -4,15 +4,15 @@ use winrt::*; import!( dependencies os - modules - "windows.media.core" - "windows.media.playback" - "windows.media.speechsynthesis" + types + windows::media::core::MediaSource + windows::media::playback::{MediaPlaybackItem, MediaPlaybackList, MediaPlaybackState, MediaPlayer} + windows::media::speech_synthesis::SpeechSynthesizer ); use log::{info, trace}; use windows::media::core::MediaSource; -use windows::media::playback::{MediaPlaybackItem, MediaPlaybackList, MediaPlayer}; +use windows::media::playback::{MediaPlaybackItem, MediaPlaybackList, MediaPlaybackState, MediaPlayer}; use windows::media::speech_synthesis::SpeechSynthesizer; use crate::{Backend, Error, Features}; @@ -139,6 +139,8 @@ impl Backend for WinRT { } fn is_speaking(&self) -> std::result::Result { - unimplemented!() + let state = self.player.playback_session()?.playback_state()?; + let playing = state == MediaPlaybackState::Playing; + Ok(playing) } }