PDA

View Full Version : Playlist data structure: SQL or something else?



ConnerP
2nd March 2016, 13:45
Hi everyone, so I am working on designing a music player using Qt and VLC as a backend. To give you an idea, I am taking a lot of inspiration from MediaMonkey. I have the library potion set up using SQL just fine, but I am not sure how to handle the playlist. The problem is a playlist should have a specific order and SQL has no inherent order.

I am not sure if keeping a field in each record to maintain that order makes sense, or if I should design an ordered data structure (or if one already exists). Does anyone have any advice on a "standard" solution for this problem? I have tried looking at Amarok source code, but have a hard time following it because it has become such a large and abstracted projected.

Thanks!

d_stranz
2nd March 2016, 16:28
SQL has no inherent order

SQL does have an order if you specify a sort field as part of your query.

Does your playlist need to be persistent? That is, do you need to save it on disk between runs of the player? If the playlist is short compared to the entire music library, then you might use XML to store it on disk. If you are already using SQL to store the music library, then it would be simpler to just add another table to the DB to store the playlist, with a column for play order and a reference to the item's key in the main library table(s).