|
| 1 | +--- |
| 2 | +title: AudioPlayer |
| 3 | +slug: /concepts/file-handling/audio-player |
| 4 | +sidebar_position: 0 |
| 5 | +tags: [Media, Widget] |
| 6 | +keywords: [Media, AudioPlayer, Play Audio File] |
| 7 | +--- |
| 8 | + |
| 9 | +# AudioPlayer |
| 10 | + |
| 11 | +The AudioPlayer widget plays audio from uploaded assets or the URL link. |
| 12 | + |
| 13 | +## Adding AudioPlayer Widget |
| 14 | + |
| 15 | +Here's how you can add the AudioPlayer widget to your project: |
| 16 | + |
| 17 | +1. Drag the **AudioPlayer** widget from the **Base Elements** tab (in the Widget Panel) or add it directly from the widget tree. |
| 18 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Audio Options** section. |
| 19 | +3. Find the **Title** property and enter the value to display the audio title. You can also set this from the variable, such as the app state variable, API response variable, Firestore document, and more. To do so, click on the **Set from Variable**. |
| 20 | +4. Find the **Path** property and enter the **URL** for the new audio file. |
| 21 | +5. By default, the audio stops when you move to another page using the **Pause on Forward Navigation** property. |
| 22 | +6. When an app goes in the background while the audio player is running, you can control the audio player's behavior using the **Play in Background** property, which has following options: |
| 23 | + 1. **Enabled**: This keeps the audio player running. |
| 24 | + 2. **Disabled, restore on foreground**: This pauses the audio player and starts playing again as soon as the app is visible. |
| 25 | + 3. **Disabled, pause**: This stops the audio player as soon as the app goes in the background. |
| 26 | + |
| 27 | +:::info |
| 28 | +By default, every AudioPlayer widget added to the project will show sample audio from the internet. |
| 29 | +::: |
| 30 | + |
| 31 | +<div style={{ |
| 32 | + position: 'relative', |
| 33 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 34 | + height: 0, |
| 35 | + width: '100%'}}> |
| 36 | + <iframe |
| 37 | + src="https://www.loom.com/embed/38c64816aac64930ac4f06d3876a1670?sid=ea8345b2-7d01-4b80-b901-a2348d5d46ce" |
| 38 | + title="" |
| 39 | + style={{ |
| 40 | + position: 'absolute', |
| 41 | + top: 0, |
| 42 | + left: 0, |
| 43 | + width: '100%', |
| 44 | + height: '100%', |
| 45 | + colorScheme: 'light' |
| 46 | + }} |
| 47 | + frameborder="0" |
| 48 | + loading="lazy" |
| 49 | + webkitAllowFullScreen |
| 50 | + mozAllowFullScreen |
| 51 | + allowFullScreen |
| 52 | + allow="clipboard-write"> |
| 53 | + </iframe> |
| 54 | +</div> |
| 55 | +<p></p> |
| 56 | + |
| 57 | +## Use Audio from assets |
| 58 | + |
| 59 | +By default, the widget is set to play audio from the internet. However, you can change this to use the audio uploaded directly to your app. |
| 60 | + |
| 61 | +Here's how you can change the audio type: |
| 62 | + |
| 63 | +1. Select the **AudioPlayer** widget from the widget tree or the canvas area. |
| 64 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Audio Options** section. |
| 65 | +3. Find the **Audio Type** dropdown and select **Asset**. |
| 66 | +4. Now, find the **Asset Audio** property, click the **Upload Audio** button, select the audio and upload it. |
| 67 | + |
| 68 | +<div style={{ |
| 69 | + position: 'relative', |
| 70 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 71 | + height: 0, |
| 72 | + width: '100%'}}> |
| 73 | + <iframe |
| 74 | + src="https://demo.arcade.software/X5tUcGCnQC7xA8jTQlGJ?embed&show_copy_link=true" |
| 75 | + title="" |
| 76 | + style={{ |
| 77 | + position: 'absolute', |
| 78 | + top: 0, |
| 79 | + left: 0, |
| 80 | + width: '100%', |
| 81 | + height: '100%', |
| 82 | + colorScheme: 'light' |
| 83 | + }} |
| 84 | + frameborder="0" |
| 85 | + loading="lazy" |
| 86 | + webkitAllowFullScreen |
| 87 | + mozAllowFullScreen |
| 88 | + allowFullScreen |
| 89 | + allow="clipboard-write"> |
| 90 | + </iframe> |
| 91 | +</div> |
| 92 | +<p></p> |
| 93 | + |
| 94 | +:::info |
| 95 | +Once you upload the audio, you can use it throughout your app. You can manage your uploaded audio files with the Project Media Asset Manager. |
| 96 | +::: |
| 97 | + |
| 98 | +To use the uploaded audio: |
| 99 | + |
| 100 | +1. Select the **AudioPlayer** widget from the widget tree or the canvas area. |
| 101 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Audio Options** section. |
| 102 | +3. Find the **Audio Type** dropdown and select **Asset**. |
| 103 | +4. Click on **No asset select** (inside the dropdown) and choose the audio. |
| 104 | + |
| 105 | +<div style={{ |
| 106 | + position: 'relative', |
| 107 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 108 | + height: 0, |
| 109 | + width: '100%'}}> |
| 110 | + <iframe |
| 111 | + src="https://demo.arcade.software/Tq8hYJxP6ZH2HAMzbeMA?embed&show_copy_link=true" |
| 112 | + title="" |
| 113 | + style={{ |
| 114 | + position: 'absolute', |
| 115 | + top: 0, |
| 116 | + left: 0, |
| 117 | + width: '100%', |
| 118 | + height: '100%', |
| 119 | + colorScheme: 'light' |
| 120 | + }} |
| 121 | + frameborder="0" |
| 122 | + loading="lazy" |
| 123 | + webkitAllowFullScreen |
| 124 | + mozAllowFullScreen |
| 125 | + allowFullScreen |
| 126 | + allow="clipboard-write"> |
| 127 | + </iframe> |
| 128 | +</div> |
| 129 | +<p></p> |
| 130 | + |
| 131 | + |
| 132 | +## Customization |
| 133 | + |
| 134 | +You can customize the appearance of this widget using the various properties available under the properties panel. |
| 135 | + |
| 136 | +### Changing colors |
| 137 | + |
| 138 | +To change the audio tile colors: |
| 139 | + |
| 140 | +1. Select the **AudioPlayer** widget from the widget tree or the canvas area. |
| 141 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Audio Player Properties** section. |
| 142 | +3. To change the background color of the tile, Find the **Fill Color** property click on the box next to the already selected color, select the color, and then click **Use Color** or click on an already selected color and enter a Hex Code directly. You can also choose the color by clicking the **Palette** and **Simple** button. |
| 143 | +4. Similarly, you can change the **Playback Button Color** (play and pause button) and **Active Track Color** (the bar color that shows the progress of the currently playing audio). |
| 144 | + |
| 145 | +### Changing elevation |
| 146 | + |
| 147 | +To change the elevation (depth or Z-axis) of the audio tile: |
| 148 | + |
| 149 | +1. Select the **AudioPlayer** widget from the widget tree or the canvas area. |
| 150 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Audio Player Properties** section. |
| 151 | +3. Find the **Elevation** input box and enter the value to see the drop shadow effect below the badge. The Higher value sets the bigger size of the shadow, whereas the 0 value removes the shadow. |
| 152 | + |
| 153 | +<div style={{ |
| 154 | + position: 'relative', |
| 155 | + paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding |
| 156 | + height: 0, |
| 157 | + width: '100%'}}> |
| 158 | + <iframe |
| 159 | + src="https://demo.arcade.software/fL5C3loHQhty5O1STFIo?embed&show_copy_link=true" |
| 160 | + title="" |
| 161 | + style={{ |
| 162 | + position: 'absolute', |
| 163 | + top: 0, |
| 164 | + left: 0, |
| 165 | + width: '100%', |
| 166 | + height: '100%', |
| 167 | + colorScheme: 'light' |
| 168 | + }} |
| 169 | + frameborder="0" |
| 170 | + loading="lazy" |
| 171 | + webkitAllowFullScreen |
| 172 | + mozAllowFullScreen |
| 173 | + allowFullScreen |
| 174 | + allow="clipboard-write"> |
| 175 | + </iframe> |
| 176 | +</div> |
| 177 | +<p></p> |
| 178 | + |
| 179 | +### Styling title text |
| 180 | + |
| 181 | +To change the title text style: |
| 182 | + |
| 183 | +1. Select the **AudioPlayer** widget from the widget tree or the canvas area. |
| 184 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Title Text Style** section. |
| 185 | +3. Find the **Theme Text Style** property and change the style as per instructions [here](../../../resources/ui/widgets/built-in-widgets/text.md#common-text-styling-properties). |
| 186 | + |
| 187 | + |
| 188 | +### Styling playback duration text |
| 189 | + |
| 190 | +To change the playback duration text style: |
| 191 | + |
| 192 | +1. Select the **AudioPlayer** widget from the widget tree or the canvas area. |
| 193 | +2. Move to the properties panel (on the right side of your screen) and scroll down to the **Playback Duration Text Style** section. |
| 194 | +3. Find the **Theme Text Style** property and change the style as per instructions [here](../../../resources/ui/widgets/built-in-widgets/text.md#common-text-styling-properties). |
0 commit comments