# Play a Sound from a variable? How can I make this code work?

**URL:** <https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974>\
**Category:** Questions about Thunkable X\
**Created:** [September 3, 2021, 7:12am UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974 "2021-09-03T07:12:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnmonline](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jnmonline](https://community.thunkable.com/u/jnmonline)\
**Post date:** [September 3, 2021, 7:12am UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974/1 "2021-09-03T07:12:58Z")

</div>

I would like to play a sound from a list. Here is a snippet of my code of what I am trying to do.

![example](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/e/fe305eefa6f2d846b74db0d513fa96d8c2087e70.png)

I am using (Drag and Drop) system btw, big thanks in advance!

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 3, 2021, 8:23am UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974/2 "2021-09-03T08:23:59Z")

</div>

You are using the variable `Soundtrack` as a list of just one item. Are you doin this purposely?

This should do what you want  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/23fd0d4cb8e76bec2f70da8483988902c73068cf.png)

However, you will need to add the .mp3 file as an asset to the project first.

---

<div class="post-metadata">

**Author:** ![jnmonline](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jnmonline](https://community.thunkable.com/u/jnmonline)\
**Post date:** [September 3, 2021, 4:18pm UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974/3 "2021-09-03T16:18:32Z")

</div>

Thank you for the reply! This works, though I do need it in a list since I will be playing multiple different tracks.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 3, 2021, 4:21pm UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974/4 "2021-09-03T16:21:03Z")

</div>

Sure,  
Check this sample app that I created for a similar request  
[https://x.thunkable.com/projectPage/60250d9ec0d1251227b520dc](https://x.thunkable.com/projectPage/60250d9ec0d1251227b520dc)

---

<div class="post-metadata">

**Author:** ![jnmonline](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jnmonline](https://community.thunkable.com/u/jnmonline)\
**Post date:** [September 3, 2021, 4:34pm UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974/5 "2021-09-03T16:34:33Z")

</div>

Thank you, this help me figure out what I wanted. I appreciate your help!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:17pm UTC](https://community.thunkable.com/t/play-a-sound-from-a-variable-how-can-i-make-this-code-work/1484974/6 "2024-11-08T13:17:00Z")

</div>


