Add reference page for isSoundPlaying() (#5868)

* add a reference page for 'is-sound-playing'

* update help path for api

* fix snippet
This commit is contained in:
Galen Nickel 2024-08-28 13:55:14 -07:00 коммит произвёл GitHub
Родитель 6d64f791ae
Коммит 2073f4222a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 41 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,40 @@
# is Sound Playing
Check if sound is playing at any sound output.
```sig
music.isSoundPlaying()
```
### ~ reminder
![works with micro:bit V2 only image](/static/v2/v2-only.png)
This function requires the [micro:bit V2](/device/v2) hardware. If you use this function with a micro:bit v1 board, you will see the **927** error code on the screen.
### ~
Sound is played at the built-in speaker or at the selected audio output pin. You can check if any sound is currently being played at any of these outputs.
## Returns
* a [boolean](/types/boolean) value that is `true` if sound is being played at the built-in speaker or at the audio pin. The value is `false` otherwise.
## Example #example
Stop all sounds if any are currently playing.
```blocks
if (music.isSoundPlaying()) {
music.stopAllSounds()
}
```
## See also
[set built-in speaker enabled](/reference/music/set-built-in-speaker-enabled),
[set audio pin](/reference/pins/set-audio-pin)
```package
music
```

Просмотреть файл

@ -68,7 +68,7 @@ void setBuiltInSpeakerEnabled(bool enabled) {
*/
//% blockId=music_sound_is_playing block="sound is playing"
//% group="micro:bit (V2)"
//% help=music/volume
//% help=music/is-sound-playing
//% weight=0
bool isSoundPlaying() {
#if MICROBIT_CODAL