The Medialib (media library) is where XMMS2 stores metadata about files as it plays them. It is implemented using an sqlite database, so queries and data updates are all performed using standard SQL queries. Having a media library allows XMMS2 to 'remember' the songs it has played, and thus allows users to easily re-create their favourite playlists.
- Collections significantly affect the way in which clients (and thus, users) interact with the medialib.
Why the medialib is
Just displaying the filename/url in the playlist isn't very attractive, so some metadata (which we call mediainfo) such as the artist's name and song's title should be retrieved. This mediainfo is generally available inside the file itself (such as the id3-tag in an mp3 file) and must be parsed. This parsing takes some time, and if it had to be done every time a song was added to the playlist, it would take some noticeable amount of time to add an album to the playlist. To solve this problem the mediainfo is cached in a database. When a song is added to the playlist, the cache is first queried, and if the song has been seen beforehand, the mediainfo will instantly be available and the operation of adding songs to the playlist will be super fast.
Since all the information about songs are kept in the database, the playlist only holds reference to its ID number. This means that big playlists will only consume sizeof(guint32)*N which gives a small footprint.
This also has a very nice side effect: all mediainfo of all songs seen will be stored in a database. This makes it possible to perform queries to find songs that have certain properties. For example, finding all songs by a certain artist or of a particular genre.
What the medialib stores
- URLs of files and streams played.
- Artist, Title, and Album.
- Arbitrary stream properties (bitrate, comments, duration, etc).
- Entire playlists, so they can be easily recalled. (In contrast with trying to find some m3u playlist saved in some obscure place..)
What can be done with the medialib
- Adding songs to the playlist, from the medialib, using Collections-queries.
- Saving and reloading entire playlists.
- For examples of what the Medialib may look like, please try existing media players that implement a similar feature - these are listed on the Wikipedia article Comparison of media players. (Note the 'Media Database' column of the 'Features' table). Please note, however, that these only provide examples of media libraries, not replicas of XMMS2's Medialib functionality.
(mlib ER diagram goes here)
There are various ways query evaluation may be optimised, with the medialib. Certain indexes may be defined to speed up common queries - however the caveat is that common queries may not be known until suitable clients are written after the developer release!