I’ve been working on a media app that calls in and plays 100+ audio files, in a shuffled order. It’s already working great (thanks to much help from fellow Thunkers!), but I don’t want audio files to repeat as often as they do.
My goal is ensure that all of these audio files areplayed only 1x before any of them are played a second time. As with the first play, they should not repeat a third time until the entire set of audio files have played a second time.
Does that make sense?
Here are the blocks I have for the shuffle. (Note: There is also looping background music, that is separate to the shuffled audio files.)
I apologise for the late reply! Thank you so much for the demo!
That was incredibly helpful for me and I understand a lot better now with the visualization.
I tried my best to adapt this into the blocks I had. It didn’t break anything (thankfully!), but it also hasn’t accomplished it. My test brought back a few repeated tracks only a few tracks in. Is there any obvious oversight here that stands out to you?
Also, at the end of the completed list in your demo, the finale is the text : “All tracks have been played” - is there an easy way to set this process to reset my list and keep playing on a loop - so that this process happens an infinite amount of times? Always repopulating when all the played tracks are done?
Thank you again for all of your help!! This is quite a journey.
I think you’d just make a copy of your track list, then use the copy for playing random tracks. Once there are no tracks left, you just repeat: copy the track list, use the copy for playing random tracks… repeat…
Thanks Tatiang! Ok… I will look at setting it up to replicate the list x infinity.
Before that though, I am still having trouble. I have 20 tracks that come into the list to stream and I am getting repeated audio before going though the list.
Do you notice where I’m going wrong? I’ve tried to replicate the demo as closely as I could with my existing blocks.
Could you please help me understand the best way to make a copy of the track list and use the copy for playing tracks (x infinity)?
I am unsure how to do this effectively without copious amounts of code… and even then it wouldn’t be set to continue forever, just as much as I’ve replicated these lists and apps.
There must be a simple way that I am missing… any help would really be appreciated!
Many thanks everyone! I really appreciate your expertise so much!
Would someone please show me the blocks that illustrates what you’ve said to do here:
“Have a variable to store the original list and whenever you want to restore it just assign this variable to the listview.items property.”
My app pulls in tracks to play into a list, then deletes them as they’re played. It stops playing when they’re all gone, but my goal is to have the list to refresh once it’s empty and replay (x infinity).
I think you’d just make a copy of your track list, then use the copy for playing random tracks. Once there are no tracks left, you just repeat: copy the track list, use the copy for playing random tracks… repeat…
There must be a simple way to do this… this isn’t working… any advice? Anyone out there? (hears echo)
I can see from your [If Block] that you are either setting the track or playing the track but not both which will result in playing few tracks only depending on the result of the random number generated.
This is @tatiang… not sure why I can’t log out and log back in as myself but… okay.
Sorry, I’m really busy with work and not on the forums as much as I’d like to be.
I don’t use local databases in Thunkable so I’m not as familiar but if you had used a list for the your track info, then you would do something like this:
This is what the app is doing: When Media screen opens, it pulls in 20 tracks from Database and plays each one, in a random order. As it plays each track, it removes this track from the list. That way, they will not play more than one time. This is great!
My Goal: After the list is all played & emptied, have the list pulled in again from the database and play each one, exactly as before. Ideally, I would like this process to continue an infinite amount of times. Keep pulling, playing, removing, restart.
I can’t figure out how to get the tracks to reload and replay after the 1st time.
Thank you so much for your time and any advice would be SO appreciated!
I think you already have what you need. The blocks in the when Media Opens event reset the track list. So just use that same set app tracks block when you need to start over.
That looks good to me but I don’t see anything calling the function “restart.” A function can’t just run on it’s own. So the if app tracks is empty block won’t actually check anything unless you have the restart function call block somewhere. But if you already have that and I just don’t see it in the screenshot AND it’s not working, it’s time to debug your code. Add some In label ____ set text to ____ blocks throughout your code (I’d start inside the restart block) and number then “1”, “2”, “3”, etc. Then watch your code to see how far it gets.
This is working perfectly now. I was missing the restart function call block.
As a beginner, I miss some of these more obvious steps. I am learning so much! I’m really enjoying the education, even though it’s frustrating at times. I appreciate all of your advice on this - it’s so exciting to see it working properly now. Awesome stuff!!!
Glad to hear it’s working! Yes, coding is always a bit frustrating for me but also quite rewarding. And I’m still learning Thunkable myself but trying to also share what I know. It helps that I have somewhat of a programming background from college.