Logo Search packages:      
Sourcecode: taglib-sharp version File versions

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

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

tag A Tag object to search in.
description A string specifying the description to match.
language A string specifying the ISO-639-2 language code to match.
A CommentsFrame 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 comment with a matching description and language.
  2. The first comment with a matching language.
  3. The first comment with a matching description.
  4. The first comment.

Definition at line 391 of file CommentsFrame.cs.

References Description, and Language.

                  /* 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;
                  CommentsFrame best_frame = null;
                  foreach (Frame frame in tag.GetFrames (FrameType.COMM)) {
                        CommentsFrame comm = frame as CommentsFrame;
                        if (comm == null)
                        bool same_name = comm.Description == description;
                        bool same_lang = comm.Language == language;
                        if (same_name && same_lang)
                              return comm;
                        int value = same_lang ? 2 : same_name ? 1 : 0;
                        if (value <= best_value)
                        best_value = value;
                        best_frame = comm;
                  return best_frame;

Generated by  Doxygen 1.6.0   Back to index