Lingo Dictionary > O-R > play() (sound) |  |

play() (sound)

Syntax

    sound(channelNum).play()
    sound(channelNum).play(member (whichMember))
    sound(channelNum).play([#member: member(whichmember), {#startTime: milliseconds, #endTime: milliseconds, #loopStartTime: milliseconds, #loopEndTime: milliseconds, #loopCount: numberOfLoops, #preloadTime: milliseconds, #rateshift: shiftAmount}])

Description

This function begins playing any sounds queued in `soundObject`, or queues and begins playing the given member.

Sound members take some time to load into RAM before they can begin playback. It's recommended that you queue sounds with `queue()` before you want to begin playing them and then use the first form of this function. The second two forms do not take advantage of the pre-loading accomplished with the `queue()` command.

By using an optional property list, you can specify exact playback settings for a sound. These properties may be optionally set:

Property | Description
--- | ---
#member | The sound cast member to queue. This property must be provided; all others are optional.
#startTime | The time within the sound at which playback begins, in milliseconds. The default is the beginning of the sound. See startTime (sound).
#endTime | The time within the sound at which playback ends, in milliseconds. The default is the end of the sound. See endTime.
#loopStartTime | The time within the sound to begin a loop , in milliseconds. See loopStartTime.
#loopEndTime | The time within the sound to end a loop, in milliseconds. See loopEndTime.
#loopCount | The number of times to play a loop defined with `#loopStartTime` and `#loopEndTime`. The default is 1. See loopCount.
#preloadTime | The amount of the sound to buffer before playback, in milliseconds. See preLoadTime.
#rateShift | The amount to increase or decrease the pitch of the sound in tonal half-steps. See rateShift.

To see an example of `play() (sound)` used in a completed movie, see the Sound Control movie in the Learning\Lingo Examples folder inside the Director application folder.

Example

This statement plays cast member introMusic in sound channel 1:

    sound(1).play(member("introMusic"))

Example

This statement plays cast member creditsMusic in sound channel 2. Playback begins 4 seconds into the sound and ends 15 seconds into the sound. The section from 10.5 seconds to 14 seconds loops 6 times.

    sound(2).play([#member: member("creditsMusic"), #startTime: 4000, \
    #endTime: 15000, #loopStartTime: 10500, #loopEndTime: 14000, #loopCount: 6])

See also

`setPlaylist(), isBusy(), pause(), playNext(), preLoadTime, queue(), rewind(), stop() (sound), getPlaylist()`