播放音效 [Music v] 到底
The Play Sound () Until Done 积木 is a 音效类积木 and a 条形积木. The block will play the specified sound, pausing its 程式 until the sound has finished playing (unlike the 播放音效 () block, which will play the sound without pausing its script).
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
重複無限次 播放音效 [Music v] 到底 end
- Using the block to have delays instead of using the 等待 () 秒 block
當收到訊息 [Start speeches v] 播放音效 [Speech1 v] 到底 播放音效 [Speech2 v] 到底 播放音效 [Speech3 v] 到底 停止 [全部 v]
Although this block plays the sound until done, it can still be interrupted during its running. 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 interruping the play while also ending the script during the sound's running. Also, if the sound is within a 广播 or 函式积木 and the script is running, if the procedure is called again, the sound will stop and the script restart. Furthermore, the 停止标志 stops all sounds, ignoring their progress.
- Main article: List of Block Workarounds
This block can be replicated with the following code:
播放音效 [recording1 v] 等待 (length of sound in seconds) 秒
This workaround requires knowing the exact length of the sound in seconds.