diff --git a/src/calibre/utils/windows/winspeech.cpp b/src/calibre/utils/windows/winspeech.cpp index 38d08f2282..365ab38bd0 100644 --- a/src/calibre/utils/windows/winspeech.cpp +++ b/src/calibre/utils/windows/winspeech.cpp @@ -470,6 +470,25 @@ class Synthesizer { synth.Options().AudioPitch(val); } + void pause() const { + player.Pause(); + } + + void play() const { + player.Play(); + } + + bool toggle() const { + switch (player.PlaybackSession().PlaybackState()) { + case MediaPlaybackState::Playing: pause(); return true; + case MediaPlaybackState::Paused: play(); return true; + default: return false; + } + } + + MediaPlaybackState playback_state() const { + return player.PlaybackSession().PlaybackState(); + } }; @@ -795,6 +814,18 @@ handle_stdin_message(winrt::hstring const &&msg) { } catch(...) { } return 0; } + else if (command == L"play") { + sx.play(); + output(cmd_id, "play", {{"playback_state", sx.playback_state()}}); + } + else if (command == L"pause") { + sx.play(); + output(cmd_id, "pause", {{"playback_state", sx.playback_state()}}); + } + else if (command == L"state") { + sx.play(); + output(cmd_id, "state", {{"playback_state", sx.playback_state()}}); + } else if (command == L"echo") { output(cmd_id, "echo", {{"msg", join(parts)}}); }