[Solved] How do I play music in a shuffled order?

Hi Everyone! :wave:

So this is what I need it to do:

I need to have a column in the Airtable with the urls to MP3s.

I need the user to click a category (EG: “stressed”) and this will start playing the Airtable “stressed” with MP3s listed.

I want the audio MP3s to play one after another, automatically (unless the user clicks “pause” or closes the screen) and these should play in a random, shuffled order, not one after another. That is also important. :slight_smile:

Does this make sense?

Thanks! :blush:


This might require a little bit of extra effort on your part @looovelee as the Sound component currently doesn’t have any Sound.stoppedPlaying event.

Do you know the track duration for each of your tracks? I would recommend adding this value, in seconds, to an additional column in your spreadsheet and this way you can use the Timer component to start change the source and start playing as soon as the song is finished.

Hope that helps.


Hi Domhall,

Thank you for the heads up! I suppose putting the length of the audio file in each row wouldn’t been too taxing. I have got as far as making an Airtable excel with sample audio files and linked the API, etc to the app.

Would anyone be able to show me a sample of the blocks to pull in this column of audio files to play? Even if it can only successfully do one. I’ve been stuck here for weeks and have no idea how to connect the link address in Airtable to my app to play any of them. The added layer of the timer component on that is really making my head spin, but maybe if I have someplace to start from I can figure that out as well…

Any guidance would be SO appreciated. I have no idea how to do this. First app. No dev experience. Trying trying trying to learn. :sweat_smile::sweat_smile::sweat_smile::sweat_smile:

Thank you!

Unsure how to proceed. These are the blocks:



Hi @looovelee,

I have 2 recommendations:

  1. Putting blocks after navigating to a new screen is not what we’d call best practise. Instead, say ‘when btn_good Click, navigate to Media’, then have certain functions trigger when the Media screen opens. Which is my next recommendation:

  2. These blocks should keep playing random tracks from your list of music indefinitely!

We use the recursive function ‘set track’. A recursive function is one that calls itself. ‘set track’ will pick a random track, then play it, then call ‘set track’ which will pick a random track, then play it, then call ‘set track’, which will… to infinity! (Or until the user presses STOP.)

When ‘set track’ randomly selects a track, it will probably not be the same as the track that was just played. In that case, we set the new Sound source, use the ‘on Source loaded’ block to play the sound, and call ‘set track’ again to keep to cycle going.

However, if the track we just selected is the same as the existing track, the ‘on source loaded’ block won’t be called! Instead, we’ll use the ‘in Sound call Play’ block to play the track again, then call ‘set track’.


Note: I used the LocalDb component in this screenshot, you can of course get an Airtable column when the screen opens as well. :slightly_smiling_face:

Let me know if this works for you,



This is the Perfect Solution :white_check_mark: :clap:


Hello Jane,

Wow! Thank you so much. Thank you for the explanation and the block screenshot. This makes a lot of sense as I read it. :grin: :clap:

I have a question now if are able to assist? :sweat_smile:

On the screen before media are 4 categories for the user to choose: good, stressed, etc. I wanted the user to navigate to Media page and only play mp3s from one category.

There is also another, separate audio file playing (background guitar) in addition to the audio tracks pulled from the table. :sweat_smile:

The goal: The user clicks a category on Screen 1 which navigates them to the Media page and then as they arrive there, the 1st background guitar starts playing on a loop. These random tracks that we are calling from the local DB table (good, mad, sad or stressed) will also begin to play (on shuffle / random) at the same time.

If the user clicks “pause”, everything pauses. They click play again everything resumes. They can leave the screen at any point and everything stops / resets. They can choose a different category next time.

Here is what I have after adding your recommended blocks. When I live test it, the background guitar is playing when I click play and none of the sample audio files from the local table are playing. I guess the blocks are contradicting each other somewhere?

Thank you again! I can’t tell you how much I appreciate the help already!


Hi @looovelee,

I think the problem is with your ‘set track’ blocks.

You’ve added an extra ‘list’ block into the ‘in list [app tracks] get #’ block.

You can see that this isn’t the case with my blocks!

Try taking this extra ‘list’ block out and test your app again.



Hello Jane,

Thank you very much. I gave that a try, but the audio tracks are still not playing for me. Only the background Guitar music.

I’ve highlighted these 2 areas below, do you think they are cancelling each other out?

Should I combine the two “when Media opens” blocks? Is that good practice?

Many thanks again!

1 Like

Nope. The platform is confusing which one to do first…

Move the backgroundGuitar - play block (from the second screen-opens block) below the set track function (in the 1st screen-opens block).

Thanks :blush:

1 Like

Hey! Thank you for the tips. :sweat_smile:

So, when I did this, no audio would play until I clicked the “pause” button.
So when I put background guitar above these blocks, it will play, but not the tracks.

My goal: Is to have both the background guitar and the tracks playing at the same time. Right now I am not hearing any of the tracks from the track list at all? Is there some way to achieve this?

1 Like

Did you put the tracks procedure under the then-do section?

Yes. I think so? :sweat_smile:

1 Like

Try adding the tracks variable above the play block.

Hey Kartik.

I tried this and have also removed all mention of the background guitar. No tracks are playing.

Is there something else missing here?

Maybe this is it… :sweat_smile:

Does the sound component support .m4a files?

Well, even so, I checked it with this sample audio and it does not work:

Hey Jane,

If you have more time, would you please see the most recent feedback I sent to Kartik. This is not working yet. I removed the second background audio to simplify it. I just want to ensure that the tracks will come in and play with the pause button activated. I can put the background audio back in after this is set up. :slightly_smiling_face:

Do you see anything else that I’ve set up wrong? :sleepy:

Many thanks!


In this one, you have the block screen1 starts instead of screen1 opens block.

This can be it, please test :innocent:

Also, I am examining your code.

1 Like

Ah yes!

I was trying a few things before. :upside_down_face:

I have it back to Media opens block. Nothing yet!

1 Like

Using .mp3 would be good instead of .m4a. Also, I have tested .mp3 files - they work.

Thanks! :blush:

Thanks! Mp3s not working for me either right now. :sweat_smile: