Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Playlist Visualization in ColumnsUI - need Help in a little script (Read 4602 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Playlist Visualization in ColumnsUI - need Help in a little script

Guys,
please forgive my dumbness with scripting languages.
I'd like to set my playlist visualization in a way that it shows some info only in the first line....for example:
If I got 2 albums of 2 different authors in the playlist, I'd like to view the name of the authors and of the albums only in the first line of each one of them (when I say "first line" I refer to the one with the first song of the album), and not in all the lines...
I think I have to go to Preferences\Display\Columns UI\Playlist View , select for example "Artist" and then write some script in the "Display" tab...
Could you help me please?
(FavPlayer)=foobar2000
(FavEnCoder)=lame390

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #1
You are on the right place, try using this code:

$if($strcmp($num(%tracknumber%,1),1),%album artist%,)

This will strip padding from the %tracknumber% tag so that it is a number. If that number equals one (the first track) then foobar will display the %album artist% tag. Foobar automatically remaps the %album artist% tag to the %artist% when not present, this is useful for various artist albums. If that number does not equal one (the rest of the tracks) then foobar will display nothing.

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #2
The same can be achieved with the following code:
Code: [Select]
$select(%tracknumber%,%album artist%)

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #3
Tnx guys! that was exactly what I was looking for...
actually I used the Yotsuya's solution 'cause in that way I was able to display the name of the artist in the first line and the title of the album in the second...
Another question: I'd like to colour the first line different to mark clearly where a new album start...
I used the "$strcmp" + the "$set_style" parameter in the style tab, like this:

Code: [Select]
$if($strcmp($num(%tracknumber%,1),1),$set_style(back,$rgb(136,223,72),$rgb(58,222,87))


...it does nothing, while if I remove the $strcmp, it colours of course all the lines

Any ideas?
(FavPlayer)=foobar2000
(FavEnCoder)=lame390

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #4
Code: [Select]
$if($strcmp($num(%tracknumber%,1),1),$set_style(back,$rgb(136,223,72),$rgb(58,222,87)))


There is one closing bracket missing: There have to be three at the end:
1. $rgb()
2. $set_style()
3. $if()

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #5
Yeah,you're right, now it works fine...tnx!
(FavPlayer)=foobar2000
(FavEnCoder)=lame390

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #6
You can use $select just fine and according to my quick test it's faster.
Code: [Select]
$select(%tracknumber%,%album artist%,%album%)

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #7
If you are planning on using more info for other tracks, like album name on the 2nd track, bitrate info on the 3rd, etc.. then $select is a much better option.

$select(%tracknumber%,
<code for first track>,
<code for second track>,
<code for third track>
)

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #8
If you are planning on using more info for other tracks, like album name on the 2nd track, bitrate info on the 3rd, etc.. then $select is a much better option.

$select(%tracknumber%,
<code for first track>,
<code for second track>,
<code for third track>
)


Ok guys, the $select works like magic...
I would never understand it by the description in the title formatting help: "Returns N-th of A,B,C... parameters."
I'm courious, do you have other example of usages of the $select parameter so I can better understand how it works?
(FavPlayer)=foobar2000
(FavEnCoder)=lame390

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #9
not really, but i think i can give a more understandable definition of the $select() function.

here goes:

$select(N,a1,a2,a3,...aN)

N is a number
a1,a2,a3,...aN are tags (strings), or code to be executed.

any tag or variable that you have created that holds a number can be the 'N' 'parameter' of the $select() function (fyi - the crap inside the parentheses are parameters)

each song may or may not have a value for the 'N' parameter that you have chosen.  if the song does not have a value, it will display/execute nothing.  however, if the song does have a value, it will SELECT the code to display/execute from the list of 'a1,a2,...aN'  not randomly of course, but based on the value of N.  if N=3, then a3 will display/execute; if N=73, then a73 will display/execute.

some examples:

ex. 1
$select(1,'you picked one','you picked two','you picked three','you picked four')

every single song will of course display -
you picked one

ex. 2
$select(3,'you picked one','you picked two','you picked three','you picked four')

every single song will of course display -
you picked three

ex. 3
$select(%discnumber%,'disc one','disc two','disc three')

every song with the tag %discnumber% set to 1 will display -
disc one

every song with the tag %discnumber% set to 2 will display -
disc two

etc...

ex. 4

$select($strchr(%album%,'a'),'an '''a''' is the first character in the album title','an '''a''' is the second character in the album title','an '''a''' is the third character in the album title','an '''a''' is the fourth character in the album title')

Album title:  apricots
Display:  an 'a' is the first character in the album title

Album title:  Breasts
Display:  an 'a' is the fourth character in the album title

Album title:  An apple a day keeps the doctor away.
Display:  an 'a' is the third character in the album title
Notes:  $strchr() is case-sensitive.  it finds only the FIRST occurence of the specified character.

I hope that brief, but hopefully brutally simple introduction to titleformatting (and specifically the $select() function) was helpful.

- teh golphcart.

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #10
thanks,
now it's pretty clear for me how it works
(FavPlayer)=foobar2000
(FavEnCoder)=lame390

Playlist Visualization in ColumnsUI - need Help in a little script

Reply #11
you're welcome.