Skip to content

Sound

Non-Visible component
Category Requires Version
Media API 21, Android 5.0 Lollipop 5

Overview

A multimedia component that plays sound files and optionally vibrates for the number of milliseconds (thousandths of a second) specified in the Blocks Editor. The name of the sound file to play can be specified either in the Designer or in the Blocks Editor.

For supported sound file formats, see Android Supported Media Formats.

This Sound component is best for short sound files, such as sound effects, while the Player component is more efficient for longer sounds, such as songs.

You might get an error if you attempt to play a sound immediately after setting the source.

Permissions

Methods

Pause

Pauses playing the sound if it is being played.

Play

Plays the sound specified by the Source property.

Resume

Resumes playing the sound after a pause.

Sound Normal

Ringer mode that may be audible and may vibrate.

Sound Silent

Ringer mode that will be silent and will not vibrate.

Sound Vibrate

Ringer mode that will be silent and will vibrate.

Stop

Stops playing the sound if it is being played.

Vibrate

Vibrates for the specified number of milliseconds.

Params
millisecs Number

Vibrate Pattern

Vibrate with a given pattern

Params
vibrate Number
delay Number
repeat Boolean

Properties

Minimum Interval (ms)

Number Default: 500 ➖ Read Write - Designer Blocks

The minimum interval, in milliseconds, between sounds. If you play a sound, all further Play() calls will be ignored until the interval has elapsed.

Source

Text ➖ Read Write - Designer Blocks

The name of the sound file. Only certain formats are supported. See http://developer.android.com/guide/appendix/media-formats.html.


Last update: November 9, 2022