BookmarkReachedEventArgs 類別

定義

BookmarkReached 事件傳回資料。

public ref class BookmarkReachedEventArgs : System::Speech::Synthesis::PromptEventArgs
public class BookmarkReachedEventArgs : System.Speech.Synthesis.PromptEventArgs
type BookmarkReachedEventArgs = class
    inherit PromptEventArgs
Public Class BookmarkReachedEventArgs
Inherits PromptEventArgs
繼承

範例

下列範例會建立包含兩個書簽的提示,並將輸出傳送至 WAV 檔案以供播放。 事件的處理常式 BookmarkReached 會在事件引發至主控台時,寫入書簽的名稱及其在音訊資料流程中的位置。

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToWaveFile(@"C:\test\weather.wav");  

        // Create a SoundPlayer instance to play the output audio file.  
        System.Media.SoundPlayer m_SoundPlayer =  
          new System.Media.SoundPlayer(@"C:\test\weather.wav");  

        // Build a prompt and append bookmarks.  
        PromptBuilder builder = new PromptBuilder(  
          new System.Globalization.CultureInfo("en-US"));  
        builder.AppendText(  
          "The weather forecast for today is partly cloudy with some sun breaks.");  
        builder.AppendBookmark("Daytime forecast");  
        builder.AppendText(  
          "Tonight's weather will be cloudy with a 30% chance of showers.");  
        builder.AppendBookmark("Nighttime forecast");  

        // Add a handler for the BookmarkReached event.  
        synth.BookmarkReached +=  
          new EventHandler<BookmarkReachedEventArgs>(synth_BookmarkReached);  

        // Speak the prompt and play back the output file.  
        synth.Speak(builder);  
        m_SoundPlayer.Play();  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  

    // Write the name and position of the bookmark to the console.  
    static void synth_BookmarkReached(object sender, BookmarkReachedEventArgs e)  
    {  
      Console.WriteLine("Bookmark ({0}) reached at: {1} ",  
        e.Bookmark, e.AudioPosition);  
    }  
  }  
}  

備註

當 物件引發 BookmarkReached 事件時 SpeechSynthesizer ,就會建立 的 BookmarkReachedEventArgs 實例。 BookmarkReached會在 SpeechSynthesizer 處理任何 SpeakSpeakAsyncSpeakSsmlSpeakSsmlAsync 方法時遇到書簽時引發 事件。 若要取得觸發事件之書簽的名稱和位置,請存取 Bookmark 事件處理常式中的 和 AudioPosition 屬性。

屬性

AudioPosition

取得到達書籤的時間位移。

Bookmark

取得所到達書籤的名稱。

Cancelled

取得值,指出非同步作業是否已取消。

(繼承來源 AsyncCompletedEventArgs)
Error

取得值,指出非同步作業期間是否發生錯誤。

(繼承來源 AsyncCompletedEventArgs)
Prompt

取得與事件相關聯的提示。

(繼承來源 PromptEventArgs)
UserState

取得非同步工作的唯一識別項。

(繼承來源 AsyncCompletedEventArgs)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
RaiseExceptionIfNecessary()

如果非同步作業失敗,引發使用者提供的例外狀況。

(繼承來源 AsyncCompletedEventArgs)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱