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 / Need Help Loading MP3s For Random Play ...

Author
Message
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 4th Oct 2004 07:53
I had an idea about allowing users to listen to whatever MP3s they want during gameplay. I set up a "root/music" folder where you could copy your MP3s and the game engine is being programmed to index this folder no matter what the contents, gather filenames and load them in. Then the game will randomly choose and play one of your songs.

My problem:
No matter how I write the code I get "music could not be loaded" error in DB Classic. I am trying to load music from an array storing file names gathered by whatever is in the directory.

My Question:
How would the code need to be written as to load music from generated array data?

Rather than specify exact filenames in quotes using the:
load music "file.ext",# format, I was using a global string array to store the filenames in.



This code snippet here is a very simple start to integrating these ideas. Any comments or suggestions are welcome.

Thanks

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro
FROGGIE!
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 9th Oct 2004 03:16
load music ""+music_playlist$(mp3),mp3

It looks like your using a comma instead of a period.

Change this line to:

load music ""+music_playlist$(mp3).mp3"

Or if that doesn't work try either

load music ""+music_playlist$(mp3)+".mp3"
load music ""+music_playlist$(mp3)+""

Hope this helps.

I should have changed my signature when asked
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 9th Oct 2004 03:29
duhh! , "" means a NULL character to strings, so you added a char 0 to the start of the string, that is not the same as the string you had returned when you scannned the folder (it`s one byte longer for a start ), the line should read

load music music_playlist$(mp3),mp3

music_playlist$ for example will contain the string "frank sinatra_I`m dreamin of a white christmas.mp3" (if your insane enough to have sinatra songs on your PC that is ), thats all the information the program would need to find the song if it was in the programs root folder, if you have the music in a folder called "songs" for example, then modify the line to read

load music "songs\"+music_playlist$(mp3),mp3

that adds the path to the songs folder onto the filename, if you have already "DIR"ed into the songs folder then you can ignore this bit , hope thats some help.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 9th Oct 2004 04:15
Quote: "It looks like your using a comma instead of a period."


that's because the (mp3) is not being used to assign an extension, it is a variable being used to track the number of mp3's

Quote: "if you have the music in a folder called "songs" for example, then modify the line to read
load music "songs\"+music_playlist$(mp3),mp3 "


you might want to note this: SET DIR Path$(3)
that's what i use to set the path by doing this at the beginning of the entire code : dim Path$(8) and then defining them like this:



- - -
i tried a lot of different syntax already including and excluding quote use and nothing has worked but thanx for the feedback peeps, i'll toy with it a little more later and post back if it works.

now that i know what quotes do (thanx Mentor), i'll keep it in mind. i also should note that this:

load music music_playlist$(mp3),mp3

is the way i originally wrote it and it's what i keep comming back to, but still getting that error from it. that is definately the bad line though. i've even tried keeping simple filenames and loaded them normally to make sure they load and play and they do, just not with this algorythm for some reason ...

i'll also try taking out my PATH command and enter the path with the LOAD MUSIC line, maybe that's the problem.

and i might change my bottom quote to "if you don't completely know what you are doing then it will be trial and error programming for you!" :p

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 9th Oct 2004 05:16 Edited at: 9th Oct 2004 05:18
Quote: "if you have already "DIR"ed into the songs folder then you can ignore this bit "


is what I said , this bit `O` code will find a file ending .mp3 in the same folder as the exe and play it, I tested it on both Classic and Pro, so you might to like to see if you have any success with this, cheers.




Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 9th Oct 2004 05:59
the whole problem seems to be here:

i want to make this:
load music playlist$(song),1

look like this:
load music playlist$(song),song

and apparently DB doesn't want me to use a variable as the music number, it seems to be forcing the use of an actual number there. try seeing if you can get the code to work by loading the music number from a variable and not a value but I'm afraid a simple one line of code using a variable is going to have to become dozens of lines using specific values because actual numbers need to be used there, so am I gonna have to write 600 lines of code just in case someone puts 600 tracks in there? or do i leave it at ten and eleven crashes the game

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 9th Oct 2004 08:12
it looks like the problem was that the system is including the folder navigations in its "gathering of files".

aye yie yie

of course you can not load "up one directory" as a music file.

by running this code:


i produced this readout which plainly shows it's list.


i havent done it yet but i think that by skipping the first two items in the list everything will be okay

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 9th Oct 2004 09:32
In your first snippit it looks like you are loading every single mp3 in the folder with LOAD MUSIC. If the user drops a few hundred (or even a few thousand) files in there it is going to attempt to load them all.

Only load the mp3 you want to play, play it, delete it and then load the next one.

Shrink dbpro exes with upx
can i scream?
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 9th Oct 2004 13:01
the_winch,

good idea. i thought of that too after seeing the music range can only be between 1 and 32

i got it to work as i was trying to anyway, for anyone interested here's the code:



it's a bit messy but it works. with some tweaking it should become another snippet for the archives. the problem i was running in to WAS the fact that the directory navigation (up one folder) were being treated as part of the perform checklist for files

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 12th Oct 2004 07:24
hence that immortal line of mine

Quote: "if right$(checklist string$(i),4)=".mp3"
load music checklist string$(i),1
endif
"


that ensures only lines ending in .mp3 get loaded, you can`t assume the folder will only ever contain what you put in it or what should be in it, users have an infinite ability to mess up your code any way they can, make sure your fileloading is bombproof, they could put all sorts of rubbish in there, cd images, wma files, jpgs even if they just copy album folder contents over, just make sure you load just what you want and nothing more.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.

Login to post a reply

Server time is: 2024-09-23 02:30:27
Your offset time is: 2024-09-23 02:30:27