# Sound component not play according to the source

**URL:** <https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372>\
**Category:** Questions about Thunkable X\
**Created:** [July 23, 2019, 3:08pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372 "2019-07-23T15:08:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicho9999](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@nicho9999](https://community.thunkable.com/u/nicho9999)\
**Post date:** [July 23, 2019, 3:08pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/1 "2019-07-23T15:08:19Z")

</div>

I’m a newbie and learning how to use sound component. I made a simple app that has 2 buttons showing a cat and a dog, and a sound component. I want to make it play a cat mp3 file when the cat button is clicked, play a dog mp3 file when the dog button is clicked.

But when the app is started, no sound is played during the first click. Then when I clicked the cat button the 2nd time, cat mp3 file was played as expected. But then when I clicked the dog button, the cat mp3 file was played again. If I clicked dog button again, the dog mp3 file will play this time.

I think I might use the sound component wrongly. Somebody please help!

The code is as follows:

 ![ThunkableApp](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/7/4702708df327a03bea835e17ebcc846b30251a2d.jpeg)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [July 23, 2019, 5:58pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/2 "2019-07-23T17:58:17Z")

</div>

Check it

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/0/803f54a173570e9ba114499e3e4480c493a13bc2.png)

---

<div class="post-metadata">

**Author:** ![nicho9999](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@nicho9999](https://community.thunkable.com/u/nicho9999)\
**Post date:** [July 23, 2019, 9:35pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/3 "2019-07-23T21:35:56Z")

</div>

With your code, the 2 buttons can trigger corresponding sound files only if I click the buttons alternatively. If I click any of the buttons consecutively, only the first time will play the correct sound file, then no matter how many times I click the same button no sound is played.

The use of sound component really confuses me. Originally I tried with only one button and used a listviewer to select the 2 animals. I changed both the picture of button and sound source after an item in listviewer was clicked. But sound played immediately after item in listviewer was picked, without waiting for me to click the picture-button. That’s why I removed the listviewer to try the more straightforward approach I showed in the first post.

FYI, I used an Android phone.

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

---

<div class="post-metadata">

**Author:** ![nicho9999](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@nicho9999](https://community.thunkable.com/u/nicho9999)\
**Post date:** [July 24, 2019, 12:02am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/4 "2019-07-24T00:02:58Z")

</div>

Your use of “on source loaded” gave me a hint, so I added some waiting time before playing. Then it works now.

But I still not sure why this happens. Is it because it needs time to load the sound file? But the sound files are assets added into the app, why do they need time to load? Originally I thought “on source loaded” is for files in URL, so there will be time lag before the app getting the sound file. But this case makes me wonder whether my concept is correct.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/1/e10723d61599e6928a91eed73f153deb5f020830.png)

---

<div class="post-metadata">

**Author:** ![CBVG](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cbvg/32/32401_2.png) [@CBVG](https://community.thunkable.com/u/CBVG)\
**Post date:** [July 24, 2019, 12:49am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/5 "2019-07-24T00:49:54Z")

</div>

Evidently, the file needs time.  
The .mp3 files can greatly vary in size, and having them as asset simply means that they are packaged with the app, not that they can dispense with the loading. The point is that sound player is only an interface to the device sound player, i.e. the component that actually drives the speaker is part of the operating system, NOT part of your application. Passing that file across has to take some time, particularly since modern portable devices tend to have multiple core CPU. The loading of the file could therefore be handled by one core, while the request to start playing the sound may be done by a different core, which will not even have noticed that the file to play was changed.

---

<div class="post-metadata">

**Author:** ![nicho9999](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@nicho9999](https://community.thunkable.com/u/nicho9999)\
**Post date:** [July 24, 2019, 1:45am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/6 "2019-07-24T01:45:50Z")

</div>

Wow 🤩 you are great! I understand now. Thank you for your detailed explanation.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [July 24, 2019, 8:35am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/7 "2019-07-24T08:35:54Z")

</div>

Using the delay in the application is not a reliable way. It is better to use this option.

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/c/2c8af3cbfee63971c5da4908236956fde8d852aa.png)

---

<div class="post-metadata">

**Author:** ![nicho9999](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@nicho9999](https://community.thunkable.com/u/nicho9999)\
**Post date:** [July 24, 2019, 11:44am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/8 "2019-07-24T11:44:40Z")

</div>

Thank you! Your code is certainly much much better than mine.

Actually I DO have concern about setting the waiting time too short and still not get the sound file loaded, if the system runs too slow.

In Thunkable Classic, I did not need to consider the problem of whether sound file has been loaded when the sound is played. So the coding is simpler. I wonder whether this is an enhanced function (though I cannot see any insufficiency in Thunkable Classic) or a problem that may be handled automatically (like Thunkable Classic) in future development?

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [July 25, 2019, 9:17am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/9 "2019-07-25T09:17:24Z")

</div>

Thunkable X has done a lot differently than Classic. I think that in Thunkable X, the Play component is performed in an asynchronous manner. That is, you can download a large mp3 and simultaneously perform other operations. You can check it if you wish.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [July 25, 2019, 2:46pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/10 "2019-07-25T14:46:51Z")

</div>

More cunning option

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/7/d7060749b00268c0a55b6c56bb56afb085e49901.png)

---

<div class="post-metadata">

**Author:** ![donavan.naidoofnw](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@donavan.naidoofnw](https://community.thunkable.com/u/donavan.naidoofnw)\
**Post date:** [August 21, 2019, 6:56pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/11 "2019-08-21T18:56:31Z")

</div>

Hi Thunkers, I have a list of songs on the firebase storage. Im a newbie to programming. How can I link a button to play 1 of the songs on the data base.

Please help.

---

<div class="post-metadata">

**Author:** ![jerryidcuxdt](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jerryidcuxdt](https://community.thunkable.com/u/jerryidcuxdt)\
**Post date:** [July 1, 2020, 2:19pm UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/12 "2020-07-01T14:19:06Z")

</div>

After your sound1.play add a line to set the source for sound1 to a blank string. If you do this, then you can hit the button as many times as you want and it will play it each time.

---

<div class="post-metadata">

**Author:** ![jonatanfeijodemeloju](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@jonatanfeijodemeloju](https://community.thunkable.com/u/jonatanfeijodemeloju)\
**Post date:** [January 30, 2021, 1:38am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/13 "2021-01-30T01:38:28Z")

</div>

Olá pode me ajudar a adicionar um som. coloquei uma imagem de uma maquina fotografica ao clicar na imagem abre a camera e a foto e tirada e lançada em outro campo de imagem, eu gostaria que o usuário ao clicar na camera, fosse emitido um som de click igual de um botão

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [March 25, 2021, 7:52am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/14 "2021-03-25T07:52:34Z")

</div>

11 posts were merged into an existing topic: [[In Progress] Sound playback not working](https://community.thunkable.com/t/in-progress-sound-playback-not-working/1178133/11)

---

<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, 11:25am UTC](https://community.thunkable.com/t/sound-component-not-play-according-to-the-source/153372/27 "2024-11-08T11:25:12Z")

</div>


