background image
C H A P T E R 1 4
Sound
14-6
Using Sound
Creating a Sound Channel for Playback
14
You create a sound channel by sending it the
Open
function.
The code that creates a sound channel for playback might look like the
following example:
mySndChn := {_proto:protoSoundChannel};
mySndChn:Open();
Playing Sounds
14
Once you create the sound channel, you can use any of the following methods to
control the sound.
Schedule
--queues the sound for play.
Start
--starts playing the sounds in the order that they were scheduled.
Stop
--stops all scheduled sounds including currently playing sounds, if any.
Pause
--temporarily stops the current playback process in the specified
sound channel.
IsPaused
--checks to see if the sound channel is paused.
IsActive
--checks to see if the sound channel is playing.
Deleting the Sound Channel
14
When finished with the sound channel, you need to dispose of it by sending the
Close
message to it. Most applications can dispose of the sound channel as soon
as playback is completed; the callback function associated with a sound frame is an
appropriate way to send the
Close
message to the channel.
Note
The system sound channel is never automatically disposed of even
if the sound channel frame is garbage collected. You must send
the
Close
message to the channel to dispose of the system
sound channel.
Playing Sound Programmatically
14
You can use any of the global functions to play sound programmatically. For
example, you might want to play a sound when the user taps a button, or when
a lengthy operation is complete. Sounds can be played synchronously or
asynchronously, as described in the following section.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна