Ejemplo n.º 1
0
ini_set('display_errors', '1');
include 'connection.php';
// read current session parameters
session_start();
session_write_close();
// fetch MPD status
$status = _parseStatusResponse(MpdStatus($mpd));
$curTrack = getTrackInfo($mpd, $status['song']);
if (isset($curTrack[0]['Title'])) {
    $status['currentartist'] = $curTrack[0]['Artist'];
    $status['currentsong'] = $curTrack[0]['Title'];
    $status['currentalbum'] = $curTrack[0]['Album'];
    $status['fileext'] = parseFileStr($curTrack[0]['file'], '.');
}
$currentpath = "/mnt/" . findPLposPath($status['song'], $mpd);
//echo $currentpath;
$flac = new Zend_Media_Flac($currentpath);
// Extract picture
if ($flac->hasMetadataBlock(Zend_Media_Flac::PICTURE)) {
    header('Content-Type: ' . $flac->getPicture()->getMimeType());
    echo $flac->getPicture()->getData();
} else {
    $ch = curl_init(ui_lastFM_coverart($status['currentartist'], $status['currentalbum'], $_SESSION['lastfm_apikey']));
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $image = curl_exec($ch);
    curl_close($ch);
    header('Content-Type: ' . mime_content_type($image));
    echo $image;
}
Ejemplo n.º 2
0
         header('Content-Type: ' . mime_content_type($local_cover_path));
         readfile($local_cover_path);
     }
 }
 // 3.0 try to find coverart on Last.FM (Album)
 if ($output === 0) {
     $cover_url = ui_lastFM_coverart($status['currentartist'], $status['currentalbum'], $lastfm_apikey, $proxy);
     if (!empty($cover_url)) {
         // debug
         runelog("coverart match: lastfm (query 1) coverURL=", $cover_url);
         $lastfm_img = curlGet($cover_url, $proxy);
         $bufferinfo = new finfo(FILEINFO_MIME);
         $lastfm_img_mime = $bufferinfo->buffer($lastfm_img);
     } else {
         // 3.1 try to find coverart on Last.FM (Artist)
         $cover_url = ui_lastFM_coverart($status['currentartist'], '', $lastfm_apikey, $proxy);
         if (!empty($cover_url)) {
             // debug
             runelog("coverart match: lastfm (query 2) coverURL=", $cover_url);
             if (!empty($cover_url)) {
                 $lastfm_img = curlGet($cover_url, $proxy);
                 $lastfm_img_mime = $bufferinfo->buffer($lastfm_img);
             }
         }
     }
     if (!empty($lastfm_img)) {
         header('Cache-Control: no-cache, no-store, must-revalidate');
         // HTTP 1.1.
         header('Pragma: no-cache');
         // HTTP 1.0.
         header('Expires: 0');