Label Parsing

From Official Kodi Wiki
Revision as of 07:23, 20 December 2007 by >Jmarshall
Jump to navigation Jump to search

In label controls and fadelabel controls, as well as in the LCD label definition files you can specify more than one piece of information to be displayed in a single line of text (or across multiple lines of text) by using the $INFO and $LOCALIZE keywords in a <label> tag. In addition to this, you can use the Label Formatting syntax to specify color and style information for the text (changeable within a single label).

Example

<xml>

 <label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label>

</xml>

How the parsing works

  1. XBMC runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.xml.
  2. XBMC then runs through and translates the $INFO[infolabel,prefix,postfix] blocks from left to right.
  3. If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block.
  4. If the Info manager returns a non-empty string from the infolabel, then XBMC prints the prefix string, then the returned infolabel information, then the postfix string. Note that any $COMMA fields are replaced by real commas, and $$ is replaced by $.
  5. Any pieces of information outside of the $INFO blocks are rendered unchanged.

So, in the above example, if nothing is playing then the label will print: A good example of a

If a song is playing but it has no Title (ie MusicPlayer.Title? returns an empty string) but does have an artist, it will return: A good example of a song artist: <Artist>

If a song is playing that has title and artist information, it will return: A good example of a song title: <Title>, and a song artist: <Artist>