Index: Slim/Music/Info.pm =================================================================== --- Slim/Music/Info.pm (revision 2184) +++ Slim/Music/Info.pm (working copy) @@ -54,6 +54,9 @@ my %lastFile = (); my %display_cache = (); +my %currentTitles = (); +my %currentTitleCallbacks = (); + my ($currentDB, $localDB); # Save our stats. @@ -314,6 +317,38 @@ }); } +sub setCurrentTitleChangeCallback { + my $callbackRef = shift; + $currentTitleCallbacks{$callbackRef} = $callbackRef; +} + +sub clearCurrentTitleChangeCallback { + my $callbackRef = shift; + $currentTitleCallbacks{$callbackRef} = undef; +} + +sub setCurrentTitle { + my $url = shift; + my $title = shift; + + if (($currentTitles{$url} || '') ne ($title || '')) { + no strict 'refs'; + + for my $changecallback (keys %currentTitleCallbacks) { + &$changecallback($url, $title); + } + } + + $currentTitles{$url} = $title; +} + +sub getCurrentTitle { + my $client = shift; + my $url = shift; + + return $currentTitles{$url} || standardTitle($client, $url); +} + sub setBitrate { my $url = shift; my $bitrate = shift; @@ -573,6 +608,13 @@ return $title; } +sub bestTitle { + my $client = shift; + my $url = shift; + + return currentSongTitle($url) || standardTitle($client, $url); +} + # get a potentially client specifically formatted title. sub standardTitle { my $client = shift; Index: Slim/Player/Protocols/HTTP.pm =================================================================== --- Slim/Player/Protocols/HTTP.pm (revision 2184) +++ Slim/Player/Protocols/HTTP.pm (working copy) @@ -228,7 +228,7 @@ $title = Encode::decode('iso-8859-1', $title); } - Slim::Music::Info::setTitle($infoUrl, $title) if $create; + Slim::Music::Info::setCurrentTitle($infoUrl, $title) if $create; ${*$self}{'title'} = $title; } @@ -485,7 +485,7 @@ if (defined($title) && $title ne '' && $oldTitle ne $title) { - Slim::Music::Info::setTitle($track, $title); + Slim::Music::Info::setCurrentTitle($track, $title); ${*$self}{'title'} = $title; Index: Slim/Player/Player.pm =================================================================== --- Slim/Player/Player.pm (revision 2184) +++ Slim/Player/Player.pm (working copy) @@ -507,7 +507,8 @@ ); } - $line2 = Slim::Music::Info::standardTitle($client, Slim::Player::Playlist::song($client)); + my $song = Slim::Player::Playlist::song($client); + $line2 = Slim::Music::Info::getCurrentTitle($client, $song); $overlay2 = $client->symbols(Slim::Display::Display::symbol('notesymbol')); ($line1, $overlay1) = $client->nowPlayingModeLines($line1); Index: Slim/Web/Pages.pm =================================================================== --- Slim/Web/Pages.pm (revision 2184) +++ Slim/Web/Pages.pm (working copy) @@ -1050,7 +1050,7 @@ $params->{'songcount'} = $songcount; $params->{'itempath'} = $song; - _addSongInfo($client, $params); + _addSongInfo($client, $params, 1); # for current song, display the playback bitrate instead. my $undermax = Slim::Player::Source::underMax($client,$song); @@ -1241,18 +1241,19 @@ $list_form{'noArtist'} = $noArtist; $list_form{'noAlbum'} = $noAlbum; + my $song = Slim::Player::Playlist::song($client, $listBuild->{'item'}); + if ($listBuild->{'item'} == $listBuild->{'currsongind'}) { $list_form{'currentsong'} = "current"; + $list_form{'title'} = Slim::Music::Info::getCurrentTitle(undef,$song); } else { $list_form{'currentsong'} = undef; + $list_form{'title'} = Slim::Music::Info::standardTitle(undef,$song); } $list_form{'nextsongind'} = $listBuild->{'currsongind'} + (($listBuild->{'item'} > $listBuild->{'currsongind'}) ? 1 : 0); - my $song = Slim::Player::Playlist::song($client, $listBuild->{'item'}); - $list_form{'player'} = $params->{'player'}; - $list_form{'title'} = Slim::Music::Info::standardTitle(undef,$song); my $track = $ds->objectForUrl($song) || do { $::d_info && Slim::Utils::Misc::msg("Couldn't retrieve objectForUrl: [$song] - skipping!\n"); @@ -1644,7 +1645,7 @@ } sub _addSongInfo { - my ($client, $params) = @_; + my ($client, $params, $getCurrentTitle) = @_; # my $song = $params->{'itempath'}; @@ -1672,7 +1673,12 @@ $params->{'track'} = $track; $params->{'filelength'} = Slim::Utils::Misc::delimitThousands($track->filesize()); - $params->{'songtitle'} = Slim::Music::Info::standardTitle(undef, $track); + if ($getCurrentTitle) { + $params->{'songtitle'} = Slim::Music::Info::getCurrentTitle(undef, $track); + } + else { + $params->{'songtitle'} = Slim::Music::Info::standardTitle(undef, $track); + } # make urls in comments into links for my $comment ($track->comment()) { @@ -1743,7 +1749,7 @@ sub songInfo { my ($client, $params) = @_; - _addSongInfo($client, $params); + _addSongInfo($client, $params, 0); return Slim::Web::HTTP::filltemplatefile("songinfo.html", $params); }