Logo Search packages:      
Sourcecode: f-spot version File versions  Download package

static SynchronisedLyricsFrame TagLib::Id3v2::SynchronisedLyricsFrame::GetPreferred ( Tag  tag,
string  description,
string  language,
SynchedTextType  type 
) [inline, static]

Gets a specified lyrics frame from the specified tag, trying to to match the description and language but accepting an incomplete match.

Parameters:
tag A Tag object to search in.
description A string object specifying the description to match.
language A string object specifying the ISO-639-2 language code to match.
type A SynchedTextType value specifying the text type to match.
Returns:
A SynchronisedLyricsFrame object containing the matching frame, or if a match wasn't found.

The method tries matching with the following order of precidence:

  1. The first frame with a matching description, language, and type.
  2. The first frame with a matching description and language.
  3. The first frame with a matching language.
  4. The first frame with a matching description.
  5. The first frame with a matching type.
  6. The first frame.

Definition at line 482 of file SynchronizedLyricsFrame.cs.

References Description, Language, and Type.

            {
                  // This is weird, so bear with me. The best thing we can
                  // have is something straightforward and in our own
                  // language. If it has a description, then it is
                  // probably used for something other than an actual
                  // comment. If that doesn't work, we'd still rather have
                  // something in our language than something in another.
                  // After that all we have left are things in other
                  // languages, so we'd rather have one with actual
                  // content, so we try to get one with no description
                  // first.

                  int best_value = -1;
                  SynchronisedLyricsFrame best_frame = null;
                  
                  foreach (Frame f in tag) {
                        SynchronisedLyricsFrame cf =
                              f as SynchronisedLyricsFrame;
                        
                        if (cf == null)
                              continue;
                        
                        int value = 0;
                        if (cf.Language == language)
                              value += 4;
                        if (cf.Description == description)
                              value += 2;
                        if (cf.Type == type)
                              value += 1;
                        
                        if (value == 7)
                              return cf;
                        
                        if (value <= best_value)
                              continue;
                        
                        best_value = value;
                        best_frame = cf;
                  }
                  
                  return best_frame;
            }


Generated by  Doxygen 1.6.0   Back to index