Random Selection of Music in Folder

Hello again all,
I need a way to randomly select a music file from my Music folder. The only way that I can see is to have a list containing all titles, but that won’t work with 6,000 songs…
Anyone know of a better way?

Why won't this work ?

Also, scroll to near the bottom of this page to see a jukebox example making a random selection from a list.

1 Like

You want me to hand code over 6000 items in a list that changes?
Can AI2 even handle a list that long?

Why not? If you can’t think of anything better Michael. Yes, it can handle a List that long.

You could be clever and learn to use Taifun’s File extension

Code like this will provide you with a List of all your songs in probably a minute or less; then use a random block to randomly select items from the list or read about how to use lists to select randomly but not repeat using Sajal’s advice on Lists

ListOfSongs but you would have to
use the link Tim provided to read about how you can use Taifun’s file control. You will also need a block like this to capture the ListFileList

Do some reading, try some blocks and if you have questions, ask politely and someone probably will provide specific advice.

Have a great weekend.

Regards,
Steve

it does not look like you followed the advice from @TIMAI2 to check the jukebox example...
well. that's unfortunate...
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Alright, I took your advice and looked up the jukebox app. It looks good, I used most of it.

The app was working fine, then I made some cosmetic changes, and now I am getting a “Runtime Error” (End Application) when launching the app.

Blocks;

Layout;

I haven’t used (or encountered) the metadata extension yet, but I would guess
you are missing the Set Data Source block in the next procedure, before the blocks
that try to show the metadata.

P.S. to upload blocks, see FAQ section: FAQ

Yup, you nailed it, thank you sir!

The fun never ends!

Now I am getting a runtime error whenever I open the app, as soon as screen1 initializes it dies.

and here’s my current blocks config;

And thanks again for sticking with me on this!

I figured it out, When I execute the “AskForPermission” AI doesn’t seem to wait for that to be answered, so I just added a delay.

that's not recommended... a user could take his/her time to grant permission or even never grant it...
better move your blocks below the AskForPermission block to the PermissionGranted event

Taifun

1 Like

As I already showed you, here:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.