# Play audio

## 👉 **The Tag** <a href="#the-tag" id="the-tag"></a>

This set of tags allows to play an MP3 track in your app.&#x20;

{% tabs %}
{% tab title="Play audio" %}

```
[action:play:URL] or [action:play]

Use [action:play] if you are getting the URL by API.
```

Plays the MP3 audio track. When this element is visible, the **pause** element will be invisible, and vice versa.

Replace `URL` with an actual URL ending in **.mp3**

**📍 Where to add the tag:** Any layer, except top-level and container.
{% endtab %}

{% tab title="Pause audio" %}

<pre><code><strong>[action:pause]
</strong></code></pre>

Pauses the MP3 audio track. This element will be invisible until user clicks the **play** element.

**📍 Where to add the tag:** Any layer, except top-level and container.
{% endtab %}

{% tab title="Progress bar" %}

<pre><code>[audio:progress:#<a data-footnote-ref href="#user-content-fn-1">FFFFFF</a>]
</code></pre>

You can change the color by setting the HEX color in the tag.

Displays a progress bar to move forward or rewind the audio track. The appearance will be the native component for each device.

**📍 Where to add the tag:** A Rectangle layer.

[See Sample Figma file](https://www.figma.com/community/file/984482687373329643?fuid=735161339401487360)<br>
{% endtab %}

{% tab title="Play audio in background" %}

```
[audio:background]
```

**Optional tag.** If this tag is included, audio files will continue playing when the app is open in the background. In order to stop the audio, users will have to return to the page where the audio was started and tap pause.

If this tag is **not** included, audio files will only play when its page is visible and will pause otherwise.\
\
Requesting a new build for your published app is required after adding this tag.&#x20;

**📍 Where to add the tag:** Any layer, except top-level and container.
{% endtab %}

{% tab title="Loading indicator" %}

<pre><code><strong>[audio:loading]
</strong></code></pre>

**Optional tag.** The element that will be displayed from the moment the **play** element is clicked until the audio file is ready to be played, along with the **pause** element.

**📍 Where to add the tag:** Any layer, except top-level and container.
{% endtab %}

{% tab title="Current played time" %}

```
[audio:currenttime]
```

Displays the progressive playing time & the total time of the audio track.

**📍 Where to add the tag:** A text layer.
{% endtab %}

{% tab title="Total time" %}

```
[audio:totaltime]
```

Displays the total time of the audio track.

**📍 Where to add the tag:** A text layer.
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Make sure your phone it's not on **mute.**
{% endhint %}

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx032qKcS4xSKGo1dg%2Faudio.gif?alt=media\&token=4660e305-e425-4734-98b1-4a17adc4e2d3)

## 🏷️ **How to add the tag** <a href="#how-to-add-the-tag" id="how-to-add-the-tag"></a>

&#x20;   1\. **Paste** the tag `[action:play:URL]` into the layer name of your **play** element (can be an icon, shape, button, or text).

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx0rnXlbVJDXrpdmE7%2Faudio1.gif?alt=media\&token=fd8d01f1-bb70-4671-becb-db4d9dba9661)

&#x20;   2\. **Paste** the tag `[action:pause]` into the layer name of your **pause** element (can be an icon, shape, button, or text).

{% hint style="info" %}
Place the **pause** element underneath the **play** element in your design file to make it look synchronized.
{% endhint %}

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx0vw9ijXdlSX_3uR1%2Faudio2.gif?alt=media\&token=da330358-d3cc-49d5-86b4-590e5d6eacc9)

&#x20;   3\. **Paste** the tag `[audio:currenttime]` into the layer name of a text layer. The placeholder time in your design will be replaced by a progressive counter in 00:00 format.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx1OKuzNrAjV2MAWqT%2Faudio3.gif?alt=media\&token=3d226264-b246-4dd6-891f-e147095779ce)

&#x20;   4\. **Paste** the tag `[audio:totaltime]` into the layer name of a text layer. The placeholder time in your design will be replaced by the real total time of the audio in 00:00 format.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx1UPefzex0OtfDoFH%2Faudio4.gif?alt=media\&token=7ab976f0-c271-4b4b-98d8-6d5dc24f5df7)

&#x20;   5\. \[OPTIONAL] **Add** the tag `[audio:background]` to the same layer where you added `[action:play:URL]`.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx1dFY_0FwnzbN5uR-%2Faudio5.webp?alt=media\&token=9948a203-c79f-4e2d-8023-5bc26266dc88)

&#x20;   6\. \[OPTIONAL] **Paste** the tag `[audio:loading]` into the layer name of your **loading** element.

{% hint style="info" %}
**Pro tip:** use the [Lottie component](https://bravo-studio.gitbook.io/docs/bravo-tags/component-lottie) to easily add a Lottie animation in your intro.
{% endhint %}

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx1lLf81w264LW1ATE%2Faudio6.webp?alt=media\&token=f88410cd-f0fb-48db-96be-c46ea3f57e1a)

&#x20;   7\. Import to Bravo & preview on Bravo Vision 🚀

## 💾 Example files <a href="#example-files" id="example-files"></a>

Duplicate the files below to see how to set it up!

{% embed url="<https://www.figma.com/community/file/982573216551611054>" %}
Figma Sample
{% endembed %}

{% file src="<https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXpqEanvOhm8vMtIH8i%2F-MhwzxgGQiel_taJHGnD%2F-Mhx2A8AdrgXXpK85OBU%2FBravo%20Sample%20-%20Audio.xd.zip?alt=media&token=828603e6-a18e-4e20-886e-449ce26cb109>" %}
Audio.xd
{% endfile %}

[^1]: Change to your custom color
