Hello, I'm writing a music player and I'm having trouble with one of the most important concepts of it: remembering songs you add to your "Library". The main draw of my music play is being quick and efficient at everything, and keeping that in mind, what would be the best way to store the user's library? A local database? A simple text file?

Thanks in advance.

Depends on how much information you want to save to a file. If it's just a number of song file names, a text file will do.

I find the best way to store binary data, and especially large amounts of binary data, is to house the file info (file size, mime-types, name, location, search tags, other meta data) in a database, or xml file if there wont be too many records, and keep the actually binary file (song, video, photo) as a stand-alone file.

This allows you to keep the path or location of the file in the database with its associated info and not try to feed the actual file-data from the database.

Why this way?
Some databases want to choke on binary data (Sqlite).
Storing the binary data in the database makes it huge, fast.
Querying the database and serving up the associated file to the browser with requisite mime-type or content-type in one procedure, without writing the file as a temp file on the server, can be tricky.

Hope this helps -- and I'm sure other people will have differing perspectives on this too.

@vegaseat: I plan to make this a very flexible music player, and I wish to make it quickly handle as many songs as possible. I try to use myself as an example, and I have at least 12,000 songs, so I think that might be out of the question.

@langsor: Thanks for the suggestion, I think I will have to go with sqlite and store the path of the song, the name, the artist, etc. in the database.

Thanks for your comments.

This question has already been answered. Start a new discussion instead.