From ea2fb28071fee9f56ebdecc6878df4801888a1bb Mon Sep 17 00:00:00 2001 From: LarsAC Date: Thu, 6 Oct 2005 13:29:31 +0000 Subject: Seek hierarchy upwards for covers if there are none in the song tags or directory git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@845 e10066b5-e1e2-0310-b819-94efdf66514b --- HISTORY | 3 ++- README | 18 ++++++++++-------- TODO | 1 + mg_image_provider.c | 23 +++++++++++++++++++---- mg_tools.c | 42 ++++++++++++++++++++++++++++++++++++++++++ mg_tools.h | 3 +++ vdr_player.c | 2 +- vdr_setup.c | 1 - 8 files changed, 78 insertions(+), 15 deletions(-) diff --git a/HISTORY b/HISTORY index c1d4411..9d059e1 100644 --- a/HISTORY +++ b/HISTORY @@ -246,11 +246,12 @@ XXXXXXXXXX: Version 0.0.8-ALPHA did not get updated. 2005-10-xx: Version 0.1.9-BETA +- adapt SQL tables for use with mySQL 5.0. The structures are compatible with GiantDisc (same changes introduced there) - Code that selects images factored out into an image provider class (mg_image_provider.h,c) - Current image provider simplay displays all images in the directory of the current song - Images are now converted in the background so that music replay starts immediately - Implement new Service interface: service ReplayDirectoryImages displays all images in directory passed via service request (char* as Data parameter to service request) - Added a patch for the image plugin (against 0.2.3) that uses muggle for displaying selected images while listening to music -- adapt SQL tables for use with mySQL 5.0. The structures are compatible with GiantDisc (same changes introduced there) - Fix for incremental search entered again +- Setup is now more verbose. NOTE: the enumeration for background mode may have changed! - Several minor fixes diff --git a/README b/README index e5fc27e..9d9c1f0 100644 --- a/README +++ b/README @@ -231,14 +231,16 @@ If a track has no ID3 tags, the following defaults will be applied: \section covers COVERS -muggle can display cover images. This is how it tries to find them: -1. if the database field album.coverimg contains something: This is - displayed. If the image file does not exist, show an error. -2. else: take the track filename and replace its extension by .jpg - if this file exists, display it -3. else try the file "cover.jpg" in the current directory. If it - does not exist, try parent directory. Repeat until the TLD is - reached. +muggle can display cover images. Currently, muggle simply displays all +images which reside in the same directory as the current file. + +#1. if the database field album.coverimg contains something: This is +# displayed. If the image file does not exist, show an error. +#2. else: take the track filename and replace its extension by .jpg +# if this file exists, display it +#3. else try the file "cover.jpg" in the current directory. If it +# does not exist, try parent directory. Repeat until the TLD is +# reached. So if you want a default background for all tracks you should put it into TLD/cover.jpg. It is strongly recommended to define such a default diff --git a/TODO b/TODO index da7019e..e502c0e 100644 --- a/TODO +++ b/TODO @@ -11,6 +11,7 @@ \subsection bugs Bugs and testing needed - Cover images from id3 tags + - When no tags in file can be found and no \subsection urgentosd OSD-related Issues - Move items within playlists diff --git a/mg_image_provider.c b/mg_image_provider.c index 2f48c22..13694c8 100644 --- a/mg_image_provider.c +++ b/mg_image_provider.c @@ -121,12 +121,27 @@ void mgImageProvider::updateItem( mgItemGd *item ) string dir = extractImagesFromTag( filename ); if( dir == "" ) { - // no images in tags, find images in the directory itself + // no images in tags, find images in the directory of the file itself dir = dirname( (char *) (item->getSourceFile().c_str()) ); - } - // finally put all image filenames here - fillImageList( dir ); + // go up hierarchy until we find at least one image or reach toplevel dir + bool toplevel_reached = false; + while( !m_image_list.size() || toplevel_reached ) + { + if( samedir( dir.c_str(), the_setup.ToplevelDir ) ) + { + toplevel_reached = true; + } + + fillImageList( dir ); + + if( !m_image_list.size() ) + { + // nothing found, turn up one directory level + dir = dirname( (char *)dir.c_str() ); + } + } + } // think of something, when there are no images here, either: // simply go up one step in the directory hierarchy, until we reach top level directory diff --git a/mg_tools.c b/mg_tools.c index 1f8654b..d691976 100644 --- a/mg_tools.c +++ b/mg_tools.c @@ -175,3 +175,45 @@ notempty(const char *s) else return strlen(s); } + +bool samedir( const char *d1, const char *d2 ) +{ + bool result; + + if( !strcmp( d1, d2 ) ) + { + result = true; + } + else + { + // check for trailing slash + int l1 = strlen( d1 ); + int l2 = strlen( d2 ); + + if( l1 == l2 + 1 ) + { + if( !strncmp( d1, d2, l2 ) && d1[l1-1] == '/' ) + { + result = true; + } + else + { + result = false; + } + } + else + { + if( l2 == l1 + 1 ) + { + if( !strncmp( d1, d2, l1 ) && d2[l2-1] == '/' ) + { + result = true; + } + else + { + result = false; + } + } + } + } +} diff --git a/mg_tools.h b/mg_tools.h index 7f63f64..c0b54c6 100644 --- a/mg_tools.h +++ b/mg_tools.h @@ -100,4 +100,7 @@ string ltos (long l); char *extension (const char *filename); bool notempty(const char *s); + +bool samedir(const char *s1, const char *s2); + #endif /* _MUGGLE_TOOLS_H */ diff --git a/vdr_player.c b/vdr_player.c index b2b828f..eb3750d 100644 --- a/vdr_player.c +++ b/vdr_player.c @@ -496,7 +496,7 @@ mgPCMPlayer::Action (void) TransferImageTFT( m_current_image ); // check for background display of image - if( the_setup.BackgrMode == 2 ) + if( the_setup.BackgrMode == 1 ) { if( m_current_image.empty() ) { diff --git a/vdr_setup.c b/vdr_setup.c index 3712c8b..98b3e86 100644 --- a/vdr_setup.c +++ b/vdr_setup.c @@ -71,7 +71,6 @@ mgMenuSetup::mgMenuSetup () Add (new cMenuEditBoolItem (tr ("Use DVB still picture"), &the_setup.UseDeviceStillPicture, tr("yes"), tr("no") ) ); - // Synchronization Add (new -- cgit v1.2.3