FRagment of code from Slim/Utils/Scanner/Remote.pm

Code:
--------------------
    
        # Parse tags and bitrate
        my $bitrate = -1;
        my $vbr;
        
        my $cl          = $http->response->content_length;
        my $type        = $track->content_type;
        my $formatClass = Slim::Formats->classForFormat($type);
        
        if ( $formatClass && Slim::Formats->loadTagFormatForType($type) && 
$formatClass->can('scanBitrate') ) {
                ($bitrate, $vbr) = eval { $formatClass->scanBitrate( $fh, 
$track->url ) };
                
                if ( $@ ) {
                        $log->error("Unable to scan bitrate for " . $track->url 
. ": $@");
                        $bitrate = 0;
                }
                
                if ( $bitrate > 0 ) {
                        Slim::Music::Info::setBitrate( $track, $bitrate, $vbr );
                        if ($cl) {
                                Slim::Music::Info::setDuration( $track, ( $cl * 
8 ) / $bitrate );
                        }       
                        
                        # Copy bitrate to redirected URL
                        if ( $track->url ne $url ) {
                                Slim::Music::Info::setBitrate( $url, $bitrate );
                                if ($cl) {
                                        Slim::Music::Info::setDuration( $url, ( 
$cl * 8 ) / $bitrate );
                                }       
                        }
                }
        }
  
--------------------


------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=109017

_______________________________________________
Squeezecenter mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/squeezecenter

Reply via email to