PDA

View Full Version : More flexible title format defination needed



Renyao
2005-08-12, 18:33
I think the title format defination is not flexible enough for me. For example,when I play English Song or Opus,I'd like to use format TITLE by ARTIST from ALBUM .When I play local or Chinese Song,however,I'd like the title format to be TITLE 演唱者:ARTIST
where "演唱者:" is Chinese meaning "sung by".

In other words,the title format should be track-driven.With different track,different format is used automatically.

Perl is very flexible in constructing dynamic subroutines.I hope
that some perl elements be used in title format defination.

For example,set a title format named "DYNAMIC EVAL TITLE" which,when selected,will eval a user-defined perl script the result of which will be used as the display title.Or set a title format named "DYNAMIC CALL TITLE" which,when selected,will call a user-defined perl dynamic sub the return value of which will be used as display title.

Slim provide the sample scripts and let users modify the sample scripts to meet their own needs just as Slim provide sample
title formats and let users choose or define their own.

In a word,the display title (especially in SB2) should be
track driven.

Grotus
2005-08-27, 19:38
Renyao blurted out:
> I think the title format defination is not flexible enough for me. For
> example,when I play English Song or Opus,I'd like to use format TITLE
> by ARTIST from ALBUM .When I play local or Chinese Song,however,I'd
> like the title format to be TITLE 演唱者:ARTIST
> where "演唱者:" is Chinese meaning "sung by".
>
> In other words,the title format should be track-driven.With different
> track,different format is used automatically.
>
> Perl is very flexible in constructing dynamic subroutines.I hope
> that some perl elements be used in title format defination.

I recently overhauled infoFormat, and it is now flexible enough to
handle something like this. It was only missing a way for plugins to
add new formatting elements. I just now committed r4100, which adds the
addFormat() command to Slim::Music::Info which will allow plugin authors
to add new format elements for use in titleformats.

So, for your purpose, you would create a plugin which has a subroutine
which examines the track object to determine the type of track, then
formats the attribution accordingly. You could call the format element
something like ATTRIBUTION (or anything else which does not currently
exist). So, your format string would be "TITLE ATTRIBUTION".

So assuming that your subroutine (which will be provided the track
object, and which should return the formatted string) is named
formatAttribution and you want to use ATTRIBUTION as the name of the
element, you would call addFormat from your plugin like this:
Slim::Music::Info::addFormat('ATTRIBUTION',\&formatAttribution);

You would call this from your initPlugin() function of your plugin.