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

Let me see if I can build some different code for you :innocent:

But before it, please confirm these points -

  • When screenSad opens, you will start the background guitar music, with a random happy music to make the user happy.
  • When he/she clicks the pause button, the background guitar music, as well as the happy music will stop. Then the resume button will appear, the pause button will hide.
  • When he/she clicks the resume button, the background guitar and the happy song resumes.

Am I right?

Thanks! :blush:

1 Like

That is 100% correct! :grin:

Thank you very much Kartik! :relaxed::clap::relaxed::clap:

1 Like

Ok.
If you are on your laptop/desktop right now, can you please open the first music link (given in the screenshot above) & post a screenshot of what appears?

I want to check whether the link redirects to a perfect/proper audio, instead of any other webpage.

How should a proper audio link look like?

:arrow_right: https://drive.google.com/open?id=1LereVcQkW_KdpwzIyaZnLV_syxTQWS5_

Thanks! :blush:

1 Like



They are mp3 links that automatically stream. 3 random sample files from this website: https://www.soundhelix.com/audio-examples

1 Like

Okay.
So, the .mp3 links are proper/perfect.

Now, I would require some time, I am making blocks according to your requirements.

I request you to stay online in the community till then, because I may ask any question to you, and you might need to provide the answer…
So you can get your code as early as possible from my side :blush:

Thanks! :blush:

1 Like

As I said, I have a question :grin: :sweat_smile:


:arrow_right: How large is your background guitar file (in MBs) :question:

Thanks! :blush:

Background guitar file is 9.69 MB.
4 mins, 14 seconds long.

I would like to also have this song on a loop. (I’m sorry, I forgot to mention that before!)

1 Like

Thank you so much!

1 Like

Thanks! :blush:

1 Like

Hey!

I am also wondering as well if I should Duplicate the Media screen 4 times for each of the 4 categories or have only 1 Media screen that somehow knows which button the user clicked to navigate to the screen (sad, mad, stressed or good) then call 4 different tables with tracks for these categories?

Someone said in this post below that duplicating screens is not the best practice.
However, it would only be 4 screens? So I wonder. What do you think?

http://community.thunkable.com/t/how-can-i-duplicate-screen-including-data/8866/6

1 Like

Since you have 4 categories, keeping 4 screens would be great.
Also, you can customize them as per the feeling - (for example background color)

  • sad - brown
  • happy - blue
  • angry - red
  • mad - (any other)

btw, duplicating screens is not a good practice, but in your case, it would be good :blush:

Thanks! :blush:

1 Like

I don’t think there’s any need to duplicate the screens - if you ever want to make a change/update/edit then you will have to do it 4 times.

Here’s an example of creating an dynamic app:

2 Likes

Hi there,

You still have the extra list block.

Your ‘set track’ block should look like this:
orig

Instead it looks like this:

So instead of saying ‘in list [app tracks]’, your blocks say ‘in list [list[app tracks]]’.
Do you see the difference?

3 Likes

Hi Jane!

Thank you so much, I completely missed this. When I amended that, the audio files began to play. I even added the background guitar and it all worked great! Thank you so much for all of your help.

1 Like

So, what percent of your problem is solved now? :stuck_out_tongue:

1 Like

About 75%! This is awesome already, so pleased to see it finally working this well. :heart_eyes_cat:
There are a few more things to iron out. :upside_down_face:

Ideally, I would like there also to be:

  1. Infinite loop for both background music and audio.

  2. A “smart shuffle” (so it does not pull the same audio files again and again, but keeps it on a new track for a set amount of few iterations. For example, when I test it, sometimes the same audio file plays 3x. )

(I’ve created a new post for the first 2 issues. I wasn’t sure if I should do that? Infinite loop of multiple sound components)

  1. Also, if I press the pause button right away, the track files do not play at all. It’s as if this cancelled the process. When I click play again and wait, background music resumes, but the tracks do not ever start. However if I enter the Media page and wait, then click pause when the app has a chance to start the tracks, they will pause and play just fine like the background music.

So happy to see it coming along! Thank you again for showing me how this works!

Thank you Domhall, this makes a lot of sense! I want to do this the best way to save work in the future. :clap:

I have a question for this app.

If the user clicks a button on Screen1 (they are “categories” = sad, mad, stressed, good) … and the button navigates them to the Media screen… how can we then tell the Media screen that the user picked / clicked that specific category?

All 4 category buttons will navigate to Media and then the Media screen needs to call the correct category of music per their selection.

I was told not to have a navigation button do any other functions, so I’m unsure how to achieve this. :sleepy:

Many thanks.