Share via


Start Method

  Microsoft Speech Technologies Homepage

Schedules an open subqueue of prompts for playback.

PromptQueue.Start()

Remarks

Scheduling prompt playback consists of beginning playback immediately, if no other prompts are currently in play, or beginning playback of the prompt subqueue immediately after the last subqueue in the PromptQueue has stopped playing back. When the final prompt in a subqueue finishes playback, and after the occurrence of the prompt element's oncomplete event, an onempty event is initiated and the status property is set to zero, indicating successful playback.

If no prompt elements are in the subqueue, including the case where all subqueues are already scheduled for playback, or a problem arises with speech playback, the Start method initiates an onerror event and sets the status property to the appropriate value.

Example

The following code demonstrates the use of the Start method.

<HTML xmlns:SALT="http://www.saltforum.org/2002/SALT">
  <HEAD>
    <script language="JScript">
      <![CDATA[   
        var intPromptCounter = 0;
        var strLogText = "!*!";
            
        PromptQueue.onempty = OnPromptQueueEmpty;
        PromptQueue.onerror = OnPromptQueueError;
        
        function fnSmexStartMonitoring(SmexID) {
          ...
        }
        function fnSmexOnReceive() {
          ...
        }
        function fnPromptInfo(PromptId) {   
          ...
        }
        function fnPromptError() {
          ...
        }
        function fnOutput(strText) {    
          LogMessage("INFORMATIONAL", strLogText + strText);
        }
        function fnLogError(strErrorText) { 
          LogMessage("ERROR", strLogText + strErrorText);
        }
        function OnPromptQueueEmpty() {
          fnOutput("PromptQueue playback has completed, the status is: " + PromptQueue.status);
          fnFinal();
        }
        function OnPromptQueueError() {   
          fnLogError("A PromptQueue error has occurred, the status is: " + PromptQueue.status);
          fnFinal();
        }
        function OnPageLoad() {    
          fnOutput("The page was loaded.");    
          fnSmexStartMonitoring(MySmex);
        }
        function OnPromptComplete() {    
          fnOutput("Prompt playback has completed for PromptQueue element number " + (++intPromptCounter));
        }
        function OnPageUnload() {    
          fnOutput("The page was unloaded.");
        }
        function fnCallConnected() {
          MyPrompt.Queue("This text is queued first.");
          MyPrompt.Queue("This text is queued second.");
          MyPrompt.Queue("This text is queued third.");
          fnOutput("Starting the PromptQueue.");
          PromptQueue.Start();
          PromptQueue.Pause();
          MySmex.timer = 2000;
        }
        function fnLocalSmexTimeout() {
          fnOutput("The timer has expired.");
          PromptQueue.Resume();
        }
        function fnFinal() {    
          fnPromptInfo(MyPrompt);
          fnSmexHangUp(MySmex);
        }
      ]]>
    </script>
  </HEAD>
  <body onload = "OnPageLoad()" onunload = "OnPageUnload()">
    <SALT:prompt id = "MyPrompt" onerror = "fnPromptError()" oncomplete = "OnPromptComplete()"/>
    <SALT:smex id = "MySmex" timer = "0" onreceive = "fnSmexOnReceive(MySmex)" ontimeout="fnLocalSmexTimeout()"/>
  </body>

See Also

PromptQueue Object |  prompt Element | oncomplete Event | onempty Event | onerror Event | status Property