Downloading resources in code

The thing is the next resource available can be any of my 50 stimuli as this is randomly assigned from the excel condition file. So, I’m not sure which one will be next.

I have followed all the steps from this post

But, I keep getting the same errors. Any help would be appreciated. I’m losing hope…

Originally, when all the resources for the experiment were being downloaded at the beginning(~2000 videos), it wouldn’t take a very long time (5-7 min). But, some browsers (i.e., chrome) wouldn’t load any of them, it would just crashed. Firefox would load some of them but not all of them. Hence, why I wanted to dynamically download only necessary resources. I think it we’re having some buffer problem. So maybe there is an easier fix here…