Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2352)

Unified Diff: chrome/browser/speech/tts_win.cc

Issue 15108002: Add Pause and Resume to Web TTS & Extension TTS APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/speech/tts_platform.h ('k') | chrome/common/extensions/api/tts.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/tts_win.cc
diff --git a/chrome/browser/speech/tts_win.cc b/chrome/browser/speech/tts_win.cc
index 06a16f599d75141a77504ebbb6a1b94741065339..bfa28743165922a524b03ccb4c98f1eb0717e572 100644
--- a/chrome/browser/speech/tts_win.cc
+++ b/chrome/browser/speech/tts_win.cc
@@ -28,6 +28,10 @@ class TtsPlatformImplWin : public TtsPlatformImpl {
virtual bool StopSpeaking();
+ virtual void Pause();
+
+ virtual void Resume();
+
virtual bool IsSpeaking();
virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE;
@@ -51,6 +55,7 @@ class TtsPlatformImplWin : public TtsPlatformImpl {
int prefix_len_;
ULONG stream_number_;
int char_position_;
+ bool paused_;
friend struct DefaultSingletonTraits<TtsPlatformImplWin>;
@@ -125,10 +130,32 @@ bool TtsPlatformImplWin::StopSpeaking() {
// Stop speech by speaking the empty string with the purge flag.
speech_synthesizer_->Speak(L"", SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL);
}
+ if (paused_) {
+ speech_synthesizer_->Resume();
+ paused_ = false;
+ }
}
return true;
}
+void TtsPlatformImplWin::Pause() {
+ if (speech_synthesizer_.get() && utterance_id_ && !paused_) {
+ speech_synthesizer_->Pause();
+ paused_ = true;
+ TtsController::GetInstance()->OnTtsEvent(
+ utterance_id_, TTS_EVENT_PAUSE, char_position_, "");
+ }
+}
+
+void TtsPlatformImplWin::Resume() {
+ if (speech_synthesizer_.get() && utterance_id_ && paused_) {
+ speech_synthesizer_->Resume();
+ paused_ = false;
+ TtsController::GetInstance()->OnTtsEvent(
+ utterance_id_, TTS_EVENT_RESUME, char_position_, "");
+ }
+}
+
bool TtsPlatformImplWin::IsSpeaking() {
if (speech_synthesizer_.get()) {
SPVOICESTATUS status;
@@ -156,6 +183,8 @@ void TtsPlatformImplWin::GetVoices(
voice.events.insert(TTS_EVENT_MARKER);
voice.events.insert(TTS_EVENT_WORD);
voice.events.insert(TTS_EVENT_SENTENCE);
+ voice.events.insert(TTS_EVENT_PAUSE);
+ voice.events.insert(TTS_EVENT_RESUME);
}
void TtsPlatformImplWin::OnSpeechEvent() {
@@ -199,7 +228,8 @@ TtsPlatformImplWin::TtsPlatformImplWin()
: utterance_id_(0),
prefix_len_(0),
stream_number_(0),
- char_position_(0) {
+ char_position_(0),
+ paused_(false) {
speech_synthesizer_.CreateInstance(CLSID_SpVoice);
if (speech_synthesizer_.get()) {
ULONGLONG event_mask =
« no previous file with comments | « chrome/browser/speech/tts_platform.h ('k') | chrome/common/extensions/api/tts.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698