public void TellStory(Story story) { if (!story.HasNextLine) { return; } // Do nothing _stories.Add(story); if (!CurrentlyPlaying) { _currentlyPlaying = true; _currentStory = story; StoryLine currentLine = _currentStory.NextLine(); _synthesizer.SelectVoice(currentLine.Voice); _synthesizer.SpeakAsync(currentLine.Line); } }
private void OnSpeakCompleted(object sender, EventArgs args) { System.Diagnostics.Debug.WriteLine("OnSpeakCompleted(sender, args)"); // Get the next line in the current story if (_currentStory.HasNextLine) { StoryLine currentLine = _currentStory.NextLine(); _synthesizer.SelectVoice(currentLine.Voice); _synthesizer.SpeakAsync(currentLine.Line); } else { int storyIndex = _stories.IndexOf(_currentStory); _stories.RemoveAt(storyIndex); // Do we have another Story if (_stories.Count > 0) { _currentStory = _stories[_stories.Count - 1]; StoryLine currentLine = _currentStory.NextLine(); _synthesizer.SelectVoice(currentLine.Voice); _synthesizer.SpeakAsync(currentLine.Line); } else { _currentStory = null; _currentlyPlaying = false; if (StoryComplete != null) { StoryComplete(this, new EventArgs()); } } } }