The audio segments illustrated in Chapter 4 simply played from beginning to end.
However, you can use this same play-audio command to control playback in different ways. To control playback, simply use an audio command other than “play” in the play-audio command.
The syntax for the play audio command is as follows:
!HAudioCommand(hwndContext, qchPath,"audiofile", "audiocommand")
This form of the command is the same as the form shown in Chapter 4, except for the audiocommand. If you simply want the animation to play from beginning to end, as in Chapter 3, audiocommand is "play". However, you can also enter the following audio commands:
Command | Description |
"stop" | Stops playing the file. |
"pause" | Pauses until reactivated. |
"auto" | Toggles between start/stop playing. |
These commands can be used with hot bitmaps to create custom audio controls.
The following examples would stop, pause, or toggle between playing and stopping for the audio segment in the ECHO.WAV file:
!HAudioCommand(hwndContext, qchPath, "sounds\\echo.wav", "stop")
!HAudioCommand(hwndContext, qchPath, "sounds\\echo.wav", "pause")
!HAudioCommand(hwndContext, qchPath, "sounds\\echo.wav", "auto")
Note that the referenced WAV file includes the path from the project directory (\VIEWER\USA) to the audio segment (SOUNDS\ECHO.WAV). Notice also that you must type double backslashes (\\) for each backslash in the path.
Summary: Inside the Project File
As shown in Chapter 4, you must register the audio command by placing the following entry in the [CONFIG] section of the title's project file, as in the following example:
[CONFIG]
RegisterRoutine("mvaudio", "HAudioCommand", "USSS")
Be sure you type the entry exactly as shown here. You only need one entry, regardless of the number of audio commands used.