TQS Home
Trivia Quiz Shell Version 2.8 Now Available!Bot Productions Home
TQS 2.5

Back to Reference

playSound Function

Plays the sound associated with a correct or an incorrect answer.

Syntax
playSound(id);
Parameters

id
Specifies which sound to play. Can be one of the following values:
0
Correct answer.
1
Incorrect answer.
Returns

There is no return value.

Remarks

The sound files associated with correct and incorrect answers are taken from the SOUND attribute of the CORRECT and INCORRECT elements. These elements must exist either within the global settings HTML or CUSTOM_* element, or directly within global settings, in order to be used by this function.

In order for any sounds to be played, the TQS element's USESSOUNDS element must be set to "1".

Use the playSoundFile function to play a specific sound file.

Example 1
<LOC ID="3" TYPE="CUSTOM_FOO">
  <CORRECT SOUND="correct.wav"/>
  <INCORRECT SOUND="incorrect.wav"/>
  <CUSTOM_FOO>
    ...
  </CUSTOM_FOO>
</LOC>
<CUSTOMDIV NAME="CUSTOM_FOO">
  ...
  <SCRIPT>
    ...
    if(answerCorrect)
      playSound(0);
    else
      playSound(1);
    ...
  </SCRIPT>
</CUSTOMDIV>
Example 2
<GLOBAL>
  <CORRECT SOUND="correct.wav"/>
  <INCORRECT SOUND="incorrect.wav"/>
  ...
</GLOBAL>
<LOC TYPE="HTML">
  ...
  <HTML>
    ...
    <BUTTON ID="correct"
      ONCLICK="playSound(0);"/>
    <BUTTON ID="incorrect"
      ONCLICK="playSound(1);"/>
    ...
  </HTML>
</LOC>

©2020 Bot Productions. All rights reserved.Last Updated: September 9, 2007