Share via


Stop Method

  Microsoft Speech Technologies Homepage

Stops playback and flushes the audio buffer.

PromptQueue.Stop()

Remarks

When playback has been stopped, the oncomplete event is not raised. If playback is already stopped, the Stop method simply flushes the audio buffer.

Return Value

None. The method sets the status property with the current status. This value is zero if there were no errors. Errors produce a non-zero code and raise an onerror event if it fails. See the onerror event description for the non-zero status codes.

Example

The following code demonstrates the use of the Stop 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() { 
          PromptQueue.Stop();  
          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 |  Resume Method | Start Method