Index: Slim/Player/Protocols/HTTP.pm =================================================================== --- Slim/Player/Protocols/HTTP.pm (revision 30488) +++ Slim/Player/Protocols/HTTP.pm (working copy) @@ -150,12 +150,13 @@ return if $handled; } - # Bug 15896, a stream had CRLF in the metadata - $metadata =~ s/[\r\n]//g; - + # Assume Icy metadata as first guess if ($metadata =~ (/StreamTitle=\'(.*?)\'(;|$)/)) { main::DEBUGLOG && $log->is_debug && $log->debug("Icy metadata received: $metadata"); + + # Bug 15896, a stream had CRLF in the metadata + $metadata =~ s/\s*[\r\n]+\s*/; /g; my $newTitle = Slim::Utils::Unicode::utf8decode_guess($1, 'iso-8859-1'); @@ -172,8 +173,33 @@ /\U$1/xg; } - # Delay the title set - Slim::Music::Info::setDelayedTitle( $client, $url, $newTitle ); + # Check for an image URL in the metadata. + my $artworkUrl; + if ( $metadata =~ /StreamUrl=\'([^']+)\'/ ) { + $artworkUrl = $1; + if ( $artworkUrl !~ /\.(?:jpe?g|gif|png)$/i ) { + $artworkUrl = undef; + } + } + + my $cb = sub { + Slim::Music::Info::setCurrentTitle($url, $newTitle, $client); + + if ($artworkUrl) { + my $cache = Slim::Utils::Cache->new( 'Artwork', 1, 1 ); + $cache->set( "remote_image_$url", $artworkUrl, 3600 ); + + main::DEBUGLOG && $directlog->debug("Updating stream artwork to $artworkUrl"); + }; + }; + + # Delay metadata according to buffer size if we already have metadata + if ( $client->metaTitle() ) { + Slim::Music::Info::setDelayedCallback( $client, $cb ); + } + else { + $cb->(); + } } # Check for Ogg metadata, which is formatted as a series of @@ -187,6 +213,9 @@ main::DEBUGLOG && $directlog->is_debug && $directlog->debug("Ogg comment: $value"); + # Bug 15896, a stream had CRLF in the metadata + $metadata =~ s/\s*[\r\n]+\s*/; /g; + # Look for artist/title/album if ( $value =~ /ARTIST=(.+)/i ) { $meta->{artist} = $1; @@ -204,6 +233,7 @@ my $cb = sub { $song->pluginData( wmaMeta => $meta ); + Slim::Music::Info::setCurrentTitle($url, $meta->{title}, $client) if $meta->{title}; }; # Delay metadata according to buffer size if we already have metadata @@ -216,26 +246,6 @@ return; } - - # Check for an image URL in the metadata. Currently, only Radio Paradise supports this - if ( $metadata =~ /StreamUrl=\'([^']+)\'/ ) { - my $metaUrl = $1; - if ( $metaUrl =~ /\.(?:jpe?g|gif|png)$/i ) { - # Set this in the artwork cache after a delay - my $delay = Slim::Music::Info::getStreamDelay($client); - - Slim::Utils::Timers::setTimer( - $client, - Time::HiRes::time() + $delay, - sub { - my $cache = Slim::Utils::Cache->new( 'Artwork', 1, 1 ); - $cache->set( "remote_image_$url", $metaUrl, 3600 ); - - main::DEBUGLOG && $directlog->debug("Updating stream artwork to $metaUrl"); - }, - ); - } - } return undef; } Index: Slim/Music/Info.pm =================================================================== --- Slim/Music/Info.pm (revision 30488) +++ Slim/Music/Info.pm (working copy) @@ -487,10 +487,9 @@ } sub setCurrentTitle { - my $url = shift; - my $title = shift; + my ($url, $title, $client) = @_; - if (($currentTitles{$url} || '') ne ($title || '')) { + if (getCurrentTitle($client, $url) ne ($title || '')) { no strict 'refs'; for my $changeCallback (values %currentTitleCallbacks) { @@ -499,6 +498,19 @@ &$changeCallback($url, $title); } } + + if ($client) { + $client->metaTitle( $title ); + + for my $everybuddy ( $client->syncGroupActiveMembers()) { + $everybuddy->update(); + } + + # For some purposes, a change of title is a newsong... + Slim::Control::Request::notifyFromArray( $client, [ 'playlist', 'newsong', $title ] ); + } + + main::INFOLOG && $log->info("Setting title for $url to $title"); } $currentTitles{$url} = $title; @@ -590,20 +602,7 @@ sub { my $client = shift || return; - my $currentTitle = getCurrentTitle( $client, $url ) || ''; - - return if $newTitle eq $currentTitle; - - setCurrentTitle( $url, $newTitle ); - - for my $everybuddy ( $client->syncGroupActiveMembers()) { - $everybuddy->update(); - } - - # For some purposes, a change of title is a newsong... - Slim::Control::Request::notifyFromArray( $client, [ 'playlist', 'newsong', $newTitle ] ); - - main::INFOLOG && $log->info("Setting title for $url to $newTitle"); + setCurrentTitle( $url, $newTitle, $client ); }, ); } Index: Slim/Player/Protocols/MMS.pm =================================================================== --- Slim/Player/Protocols/MMS.pm (revision 30488) +++ Slim/Player/Protocols/MMS.pm (working copy) @@ -390,6 +390,7 @@ $song->pluginData( wmaMeta => { title => $1, } ); + Slim::Music::Info::setCurrentTitle($url, $1, $client); }; # Delay metadata according to buffer size if we already have metadata @@ -419,6 +420,7 @@ my $cb = sub { $song->pluginData( wmaMeta => $meta ); $song->pluginData( wmaHasData => 1 ); + Slim::Music::Info::setCurrentTitle($url, $meta->{title}, $client) if $meta->{title}; }; # Delay metadata according to buffer size if we already have metadata @@ -444,6 +446,7 @@ my $cb = sub { $song->pluginData( wmaMeta => $meta ); $song->pluginData( wmaHasData => 1 ); + Slim::Music::Info::setCurrentTitle($url, $meta->{title}, $client) if $meta->{title}; }; # Delay metadata according to buffer size if we already have metadata