# Sound

## Set Source

There are a few ways you can set a sound source in your app:

1. **Upload a sound to your app.** Be careful of the Thunkable 50 MB [app size limit](https://docs.thunkable.com/snap-to-place/projects/assets#app-size-limits-50-mb-per-app)
2. **Provide a link to the sound.** The link has to end in `.mp3`, `.wav`, etc

## Volume

You can set a volume for the Sound component between 0 and 100.

## Interruption Mode Android

The available options for Android are Duck Others and Do Not Mix.

Duck Others: This is the default option. If this option is set, your sound lowers the volume ("ducks") of audio from other apps while your audio plays.

Do Not Mix: If this option is set, your sound interrupts audio from other apps.

## Interruption Mode iOS

The options for iOS are Duck Others, Mix With Others, and Do Not Mix.

Duck Others: If this option is set, your sound lowers the volume ("ducks") of audio from other apps while your selected audio plays.

Mix With Others: This is the default option. If this option is set, your sound is mixed with audio playing in background apps.

Do Not Mix: If this option is set, your selected sound interrupts audio from other apps.[<br>](https://docs.expo.dev/versions/latest/sdk/audio/#donotmix-1)

{% hint style="info" %}
Keep in mind that the outcome depends on the interruption mode set by the other app playing the audio.
{% endhint %}

## Muted

If this switch is set to true, the sound is muted.

## Blocks

### Events

### On Source Loaded

This block will be triggered when the source of a Sound component is loaded. It is recommended to use this block if changing a Sound component's source during app runtime.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYd_lTEaohL_ctrHTZB%2F-MYdbGZGVz6p1KnLJYRW%2Fsourceloaded.png?alt=media\&token=0965780d-9ddf-4f2f-87f1-d9e0c39d9a55)

If a given audio is already the source of a Sound component, and you use a block to set the same audio as the source of the Sound component, this block will not be triggered. We recommend using an [if statement](https://docs.thunkable.com/snap-to-place/control#if-this-do-that) to say that if the audio is already the source of the Sound component, execute the action you would take when the source is loaded.&#x20;

In the following screenshot, we want this audio to play when the Button is pressed. If this audio is already the source for the Sound component, we play the sound. If not, we set the audio to be the Sound's source. Once the source is loaded, we play the audio.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-M_Qcs_SKXesyXo06FKJ%2F-M_QdpOlKOrSwohEH-w6%2FScreen%20Shot%202021-05-11%20at%202.38.35%20PM.png?alt=media\&token=f5686088-f533-42ec-9109-e40bef86bddb)

### Ends

This block will be triggered when a sound stops playing.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2F1qlNEbsFKjz62eJgxddl%2Fimage.png?alt=media&#x26;token=14e618de-0b1e-46f7-91a1-c0ffb7db9506" alt="" width="563"><figcaption></figcaption></figure>

### On Error

This block will be triggered if there is an error with the Sound component.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYd_lTEaohL_ctrHTZB%2F-MYdbNDFbWlYHum_PLNv%2Ferror.png?alt=media\&token=c62ccce4-43a8-4359-98d4-6d9faa43dada)

### Functions

### Play

Use this block to play the selected sound from the drop-down menu.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FyzOLKx0bNafWmqv1QpQA%2Fimage.png?alt=media&#x26;token=cba05519-f356-41fc-92c4-3aa38469f2a2" alt="" width="563"><figcaption></figcaption></figure>

### Play from

This block plays the selected sound starting from the second you choose.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FDbSdqkUYKkY1uA7oKuX1%2Fimage.png?alt=media&#x26;token=4cc1e1e6-b01a-44e3-860d-8635658346bb" alt="" width="563"><figcaption></figcaption></figure>

### Play as Effect

Use this block to play the selected sound from the drop-down menu as an effect.

This sound can't be stopped or paused.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FiDqBLcEbwvteInWb17DW%2Fimage.png?alt=media&#x26;token=b8099800-d635-4144-8f62-480887c4c187" alt="" width="563"><figcaption></figcaption></figure>

### Pause

Use this block to pause the selected sound from the drop-down menu.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FJrniHqpjA96KUqhD2A0d%2Fimage.png?alt=media&#x26;token=b02e2079-9138-43f9-afe9-8d72dbc126f5" alt="" width="563"><figcaption></figcaption></figure>

### Resume&#x20;

Use this block to resume the selected sound from the drop-down menu.

A sound can only be resumed if it has been paused.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FGHXecwh9ThA5WwWzOpIY%2Fimage.png?alt=media&#x26;token=2e7c766e-fdbb-49b3-91ee-6f9ee96ca9bb" alt="" width="563"><figcaption></figcaption></figure>

### **Is Playing?**

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FJoqkQH6U4sLtFwlOZZGL%2Fimage.png?alt=media&#x26;token=06435a1a-bf28-4da1-a22b-d4abf79af3a6" alt=""><figcaption></figcaption></figure>

Returns `true` or `false` value for whether this sound is playing.

### **Is buffering?**

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2Fouw5jCLLWeNs6dO1thWD%2Fimage.png?alt=media&#x26;token=baf9b46c-8ee4-414a-8003-a70b291bc8e9" alt=""><figcaption></figcaption></figure>

Returns `true` or `false` value for whether this sound is loading.

### **duration**

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2F6J1sKzT6zGyel3eAYLyF%2Fimage.png?alt=media&#x26;token=92078450-edc6-4d4d-a4ea-f30316197487" alt=""><figcaption></figcaption></figure>

Returns the total duration of this sound in seconds.

### time

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FVZgE1KYCLMYaIVzo6r5C%2Fimage.png?alt=media&#x26;token=2c6a6258-ea36-49c8-a7eb-4380d7d7e5ff" alt=""><figcaption></figcaption></figure>

Returns the sound's specific time in seconds.

### **Stop**

Use this block to stop the selected sound from the drop-down menu.

<div align="left"><figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FF5HDjxBOlwENDZXFCX2b%2Fimage.png?alt=media&#x26;token=279f9277-391c-4168-b60e-191ecb5453e0" alt="" width="560"><figcaption></figcaption></figure></div>

### Set/Get Source

Set the Sound's source using the drop-down menu or by using a [Text](https://docs.thunkable.com/snap-to-place/text) block to specify a filename or a URL.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FQN6Atu4fIxNAlRQ4rfUV%2Fset%20source.png?alt=media&#x26;token=370f89d6-71d2-4280-9702-5bfbcccdb3cd" alt=""><figcaption></figcaption></figure>

Get the name of the Sound source.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FyCGhvh0NcRrJh9z861ql%2Fget%20source.png?alt=media&#x26;token=30b7275e-a7ef-4a11-8565-d0eb4d360871" alt=""><figcaption></figcaption></figure>

### Set/Get Volume

Set the Sound volume to a value between 0 and 100.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FNfqsmsRlDbNQSzzKKSoc%2Fget%20volume.png?alt=media&#x26;token=c8581591-f9c7-475e-9219-15770747c873" alt=""><figcaption></figcaption></figure>

Get the Sound volume.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FcuvhfWIznJK9fbcjPA7k%2Fget%20volumee.png?alt=media&#x26;token=fe98c560-5164-471d-8656-99d9c9dc5aaa" alt=""><figcaption></figcaption></figure>

### Set/Get Interruption Mode

Set Sound Interruption Mode on Android/iOS to a value between Duck Others, Mix With Others and Do Not Mix.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FOEZh2x125vg3X6KZ3OfH%2Finterruption%201.png?alt=media&#x26;token=2feb1a49-6138-445c-930a-5070483747f8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FVJZPg31VOQSzXTEoOnIJ%2Finterruption%203.png?alt=media&#x26;token=0c3da4e5-b6f9-4610-aabe-614f944a6706" alt=""><figcaption></figcaption></figure>

Get the Interruption Mode on Android.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2F73DxuHAdTIfZDe77fhpj%2Finterruption%202.png?alt=media&#x26;token=a64e0172-962d-4a9b-8e42-f35fc24b8860" alt=""><figcaption></figcaption></figure>

Get the Interruption Mode on iOS.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2Fq8Ey83iSqc1hTpFnuZZ3%2Finterruption%204.png?alt=media&#x26;token=e5b42470-08c7-462d-92f3-49d513a76db2" alt=""><figcaption></figcaption></figure>

### Set/Get muted

Mute or unmute the sound by setting the value to True or False.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FyWOB8FbVbIXaXL9ALioK%2Fset%20muted.png?alt=media&#x26;token=fb690576-5020-468e-be95-4752b7c01d05" alt="" width="563"><figcaption></figcaption></figure>

Get the value (True or False) if the sound is muted.

<figure><img src="https://689802330-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUe3rgJfvQYLrpDR1HfWv%2Fuploads%2FJV89T1AfOWMoD3guC9Tc%2Fget%20muted.png?alt=media&#x26;token=cf0a9fe8-852b-4c3a-aa7d-a3a08e6a20e9" alt="" width="563"><figcaption></figcaption></figure>
