Play Sound () Until Done
play sound ( v) until done
Category Sound
Type Stack

The Play Sound () Until Done block is a Sound block and a stack block. The block will play the specified sound, pausing its script until the sound has finished playing (unlike the Start Sound () block, which will play the sound without pausing its script).

In the Experimental Viewer, early versions of the Scratch 2.0 alpha, and early versions of Scratch 1.x, the block was called Play Sound () and Wait.

Example Uses

As this block plays a sound and pauses its script until the sound is done, it is mainly used when a sound must be played and the script must be kept from continuing until the sound has finished playing.

Some common uses for the Play Sound () Until Done block:

  • Looping a music track, such as for background music
forever
   play sound (Music v) until done
when I receive [Start speeches v]
play sound (Speech1 v) until done
play sound (Speech2 v) until done
play sound (Speech3 v) until done
stop [all v]

Interruption

Although this block plays the sound until done, it can still be interrupted during its running. It is important to note that it will stop running after it finished once. There are some ways for the block to be interrupted and stop playing the sound:

  • The Stop All Sounds block will, of course, stop the sound.
  • The Stop () block also has the capability of interrupting the play while also ending the script during the sound's running.
  • Also, if the sound is within a broadcast or custom block and the script is running, if the procedure is called again, the sound will stop and the script will restart.
  • Furthermore, the stop sign stops all sounds, ignoring their progress.

Workaround

Main article: List of Block Workarounds

This block can be replicated with the following code:

start sound (recording1 v)
wait (length of sound in seconds) seconds

This workaround requires knowing the exact length of the sound in seconds.

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.