Kodi Community Forum

Full Version: label parts with conditional visibility
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm displaying the next 10 tracks while playing music. When I startup there is an m3u that is set to play in random order and this is fine. What is displayed is:
TrackNumber Artist: TrackTitle
And that looks ok because the m3u is a compilation of various artists.
The problem is that when I go to my music folders, I turn off the random play and play an album. Now it doesn't look fine because every track has the same artist.
I'd like to display two arrangements:
TrackNumber Artist: TrackTitle (when startup - random on)
or:
TrackNumber TrackTitle (playing an album - random off)
That is, drop the Artist name when playing an album

I've looked at another thread with
<label> $IF[condition,display1 if condition met,display2 if condition not met]</label>
I'm just not sure how to word the condition, based on whether random is on or off
Code:
Playlist.Random     Returns string ID's 590 (Randomize Play Enabled) or 591 (Disabled)

So you need to this condition -

PHP Code:
StringCompare(Playlist.Random,$LOCALIZE(590)) 
Ok, as an example, here is the label for one of the tracks. To my understanding this should yield Artist: Title when random enabled and just Title when random disabled

<label>$IF[StringCompare(Playlist.Random,$LOCALIZE(590)),$INFO[MusicPlayer.offset(1).Artist]: $INFO[MusicPlayer.offset(1).Title], $INFO[MusicPlayer.offset(1).Title]]</label>

I tried it and it displayed the string compare bit ... as text.
Can you see anything wrong with the script?
There's no $IF control in XBMC so I don't know where that's come from, you need to use the condition in a label control or variable control.

ie

PHP Code:
<control type="label">
<
label>$INFO[MusicPlayer.offset(1).Artist]: $INFO[MusicPlayer.offset(1).Title], $INFO[MusicPlayer.offset(1).Title]</label>
<
visible>StringCompare(Playlist.Random,$LOCALIZE(590))</visible>
</
control

or

PHP Code:
<control type="label">
<
label>$VAR[NowPlayingLabel]</label>
</
control

PHP Code:
<variable name="NowPlayingLabel">
<
value condition="StringCompare(Playlist.Random,$LOCALIZE(590))">$INFO[MusicPlayer.offset(1).Artist]: $INFO[MusicPlayer.offset(1).Title], $INFO[MusicPlayer.offset(1).Title]</value>
<
value>$INFO[MusicPlayer.offset(1).Title], $INFO[MusicPlayer.offset(1).Title]</value>
</
variable
Thanks Hitcher, I used the first code. The label was permanently invisible. I tried changing to 591 in case I was imagining it was random but no luck
Can you pastebin your complete code?
http://pastebin.com/tYBrAGs1
This is one of 12 label sets showing the next tracks
Try -

PHP Code:
<control type="label">
    <
description>Track 1 title</description>
    <
visible>!IsEmpty(MusicPlayer.Offset(1).Title) + SubString(Playlist.Random,$LOCALIZE(590))</visible>                                      
    <
posx>30</posx>
    <
posy>220</posy>
    <
height>30</height>
    <
width>800</width>
    <
label>[COLOR=lightblue]$INFO[MusicPlayer.offset(1).Artist]:[/COLOR]  $INFO[MusicPlayer.offset(1).Title]</label>
    <
align>left</align>
    <
aligny>Top</aligny>
    <
font>font8</font>
    <
textcolor>bisque</textcolor>
    <
shadowcolor>black</shadowcolor>
    <
scroll>true</scroll>
</
control>

<
control type="label">
    <
description>Track 1 title</description>
    <
visible>!IsEmpty(MusicPlayer.Offset(1).Title) + SubString(Playlist.Random,$LOCALIZE(591))</visible>                                      
    <
posx>30</posx>
    <
posy>220</posy>
    <
height>30</height>
    <
width>800</width>
    <
label>[COLOR=lightblue]$INFO[MusicPlayer.offset(1).Artist]:[/COLOR]  $INFO[MusicPlayer.offset(1).Title]</label>
    <
align>left</align>
    <
aligny>Top</aligny>
    <
font>font8</font>
    <
textcolor>bisque</textcolor>
    <
shadowcolor>black</shadowcolor>
    <
scroll>true</scroll>
</
control
Didn't work Sad The title was not visible when random was on or off
Solved it!. I went to the list of Boolean conditions. The condition is : Playlist.IsRandom and the opposite being : !Playlist.IsRandom