Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / get random music in folder??

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 1st Sep 2006 02:26 Edited at: 1st Sep 2006 02:28
how would i get a random mp3 song from a folder & have dbp play it??

same question(sort of),but how would i get a random image in a folder & have dbp load it????

i know how to set the directory for the folder,the rest i dont know about.

example of what i want to do:
if any of u have played morrowwind,all you have to do for morrowwind to play your songs is to put your mp3 into the musics folder,i want to do the same thing.


??

Trowbee
21
Years of Service
User Offline
Joined: 12th Apr 2003
Location: United Kingdom
Posted: 1st Sep 2006 03:34 Edited at: 1st Sep 2006 03:45
This is off the top of my head, but should work fine:



EDIT:
Probably be better I add how it works:

perform checklist for files will get a list of all files, currently in the directory specified by set dir
checklist quantity will then return how many files there are in said directory, plus 2.
1: Current directory
2: Parent directory
3: File number 1
4: File number 2
and so on
if checklist quantity()>=3 just checks that the number DB see's is bigger than (or equal to) 3 (or 1 or more real files exist). If it does, it executes;
randomize perftimer() sets the random seed, to make it all random. timer() is usually used, and is fine, but perftimer() is more accurate.
filename$ is then assigned a filename, based on checklist quantity.
2+int(rnd(checklist quantity()-2)) works, by taking checklist quantity(), and subtracting 2 (to find the number of real files, picking a random number, making it int, and adding 2 (to put back into DB).


Then, you need to write your own code to load the filename.

You could infact tidy the code, and put it in a function:

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 1st Sep 2006 16:11
hmm. thanks,ill test it & see if it works.
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 2nd Sep 2006 20:32
well,i tested it but dbp crashes when i run it.

this is my code i was trying:



Trowbee
21
Years of Service
User Offline
Joined: 12th Apr 2003
Location: United Kingdom
Posted: 2nd Sep 2006 20:41
almost

The FindRandomFile function returns the filename (although I see where a slight edit is needed).

Try this:

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 3rd Sep 2006 03:30 Edited at: 3rd Sep 2006 03:31
it didnt work at 1st because i forgot to add \ to the end of my path,but after that it works great!!

thankyou so much Trowbee!!

i think u should add your code to the codebase or code snippets,its really good!

thanks!!

Login to post a reply

Server time is: 2024-11-26 11:37:08
Your offset time is: 2024-11-26 11:37:08