Finding music?

Blitz3D Forums/Blitz3D Programming/Finding music?

I've been trying to figure this out for a while now, but I can't seem to think of a way of doing it.
Basically, I want my game to be able to open and play user-added music. Eg. you put the file "Music.wav" in the directory "C:\my game\music\", and then when you run "my game.exe", "Music.wav" is playing in the background. Only problem is, without forcing the user to actually rename their favourite track to "Music.wav", blitz won't be able to open it (because it won't know what the music file is called).
Can anyone help me with this?

Is this going to be just one file? thats allowed in that directory?


myDir=ReadDir(folder$) 

; Let's loop forever until we run out of files/folders to list! 
Repeat 
; Assign the next entry in the folder to file$ 
file$=NextFile$(myDir) 

; If there isn't another one, let's exit this loop 
If file$="" Then Exit 

; Use FileType to determine if it is a folder (value 2) or a file and print results 
If FileType(folder$+""+file$) = 2 Then
	If Instr(file$,".mp3") Then
		Print "File:" + file$
	EndIf
End If 
Forever 

; Properly close the open folder 
CloseDir myDir 



You will be abe to see whats going on

Well, multiple files would be good but one file would be ok as well.

i made an edit... see that code

in this case, i made it look only for .mp3

Thanks, but doesn't seem to be working, probagbly because I'm being stupid (as usual). If I put this in any old directory, and put a .mp3 file in the same directory, will the program recognise it?

Say you have a the program here
c:\mygame\project.exe

and you have music here
c:\mygame\music

and your music files are there

all you need is "music/" and as the path$ that shoud do it

Ok, thanks :)

There is also a command (I think PlayCDMusic)??? that will play a cd track, so the user could put in their favourite cd