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.

Recommended Answers

All 3 Replies

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.

Member Avatar for langsor

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.