Media Pictures (mediapics)
From LinuxMCE wiki
LinuxMCE media pictures are the picture files associated to media files (.mp3, .mov, DVD). There are three ways to associate a picture to a media file:
- Use LinuxMCE-admin, Files & Media > Media Files Sync a choose a media file. You can upload a picture and associate it with a media file or choose an attribute of one or more media files and set a picture file for it/them.
- When you rip a DVD and using CDDB, the cover art of the DVD is automatically downloaded and associated with the stored DVD file. Same thing when you only play a DVD.
- Use UpdateMedia daemon which indexes the media files for the media folders and eventually downloads the image for a mp3 or any file which has id3 tags.
The media pictures are stored in /home/mediapics. There are two picture files created: the cover art "/home/mediapics/<picture_id>.<ext>" and the thumbnail "/home/mediapics/<picture_id>_tn.<ext>"
An example: /home/mediapics/1.jpg and its thumbnail, 1_tn.jpg (scaled down to 256x256 pixels). The filename match the value of Picture.PK_Picture in database pluto_media.
In the database schema from the following picture, you can see that you can associate a picture to a file and one picture for each of the file's attributes. The database used is pluto_media.
The filegrid from Orbiter is populated using File_Grid_Plugin's FileListGrid::ToData method. The way the pictures are shown in Orbiter is:
- if the file has a picture associated, that picture will be shown
- if no picture is associated directly to the file, FileListGrid will look over file's attribute and display the picture which of the attributes with the type having the minimum PicPriority.
Orbiter and how it gets the pictures
For filegrid for music, movies and videos, Orbiter sends a "Populate datagrid" command to Datagrid_Plugin which routes the command to "File_Grid_Plugin" which has the datagrid generator "File_Grids_Plugin::FileList" method registered for DATAGRID_Directory_Listing_CONST datagrid. Then Orbiter send a "Request Datagrid Contents" command to Datagrid_Plugin which will call FileListGrid::ToData.
By default, USE_PRECACHED_DATABASE_MAP is defined in FileListGrid. This will activate the code which gets the right picture for each file from the specified folder, using the database. It is done using a single SQL query and the data will be pre-cached and used for each file.
If USE_PRECACHED_DATABASE_MAP is not defined, the picture for each file will be retrieved from the id3 tags for each files. The profiling performed on this code shown that using pre-cached database data is faster the using id3 tags in this case.
SQL Statements - To retrieve data manually for development and debugging purposes
List your media files:
SELECT PK_File,Path,Filename FROM File;
List coverart attached to media files:
SELECT Path,Filename,PK_Picture,Extension FROM File INNER JOIN Picture_File ON PK_File=FK_File INNER JOIN Picture ON FK_Picture=PK_Picture;
List specific media file:
SELECT Path,Filename,PK_Picture,Extension FROM File INNER JOIN Picture_File ON PK_File=FK_File INNER JOIN Picture ON FK_Picture=PK_Picture WHERE PK_File=<number>;
<number> correspond to the number(PK_File) you get from the first select statement.