Ejemplo n.º 1
0
function getStatus()
{
    $app = Slim\Slim::getInstance();
    $app->contentType('application/json');
    $playing = getCurrent();
    //$log = $app->getLog();
    //$log->info("-> getStatus " + $playing);
    $root_dir = getOption('root');
    exec('pgrep omxplayer.bin', $pids);
    $body = array();
    $body['running'] = empty($pids) ? false : true;
    if ($playing && !empty($pids)) {
        $playing = trim($playing);
        $file = str_replace($root_dir . "/", "", $playing);
        if (getOption("id3")) {
            $au = new AudioInfo();
            $audioinfo = $au->Info($root_dir . "/" . $playing);
            //print_r($audioinfo);
            if (isset($audioinfo['comments']['artist'])) {
                $body['artist'] = $audioinfo['comments']['artist'][0];
            }
            if (isset($audioinfo['comments']['title'])) {
                $body['title'] = $audioinfo['comments']['title'][0];
            }
            if (isset($audioinfo['comments']['album'])) {
                $body['album'] = $audioinfo['comments']['album'][0];
            }
            if (isset($audioinfo['comments']['genre'])) {
                $body['genre'] = $audioinfo['comments']['genre'][0];
            }
            if (isset($audioinfo['comments']['track'])) {
                $body['track'] = $audioinfo['comments']['track'][0];
            }
            if (isset($audioinfo['comments']['year'])) {
                $body['year'] = $audioinfo['comments']['year'][0];
            }
            if (isset($audioinfo["playtime_string"])) {
                $body['playtime'] = $audioinfo["playtime_string"];
            }
            if (isset($audioinfo["format_name"])) {
                $body['format'] = $audioinfo["format_name"];
            }
            if (isset($audioinfo["bitrate_mode"])) {
                $body['bitrate_mode'] = $audioinfo["bitrate_mode"];
            }
            if (isset($audioinfo["bitrate"])) {
                $body['bitrate'] = $audioinfo["bitrate"];
            }
            if (isset($audioinfo['video']['resolution_x']) && isset($audioinfo['video']['resolution_y'])) {
                $body['resolution'] = $audioinfo['video']['resolution_x'] . "x" . $audioinfo['video']['resolution_y'];
            }
        }
        $file = str_replace($root_dir . "/", "", $playing);
        $body['file'] = end(explode("/", $playing));
        $body['link'] = $file;
    }
    echo json_encode($body);
    $response = $app->response();
    $response["Cache-Control"] = "max-age=5";
}
Ejemplo n.º 2
0
 function createAudio($pid, $mp3, $imageLengthArray)
 {
     $audioTxt = "";
     $outputPath = $this->root . "/Video/CreatedVideos/" . $pid . "/audio/";
     if (!file_exists($outputPath)) {
         mkdir($outputPath, 0777, true);
     }
     //Save audio locally
     $localfile = $outputPath . "audio1.mp3";
     $data = file_get_contents($mp3);
     file_put_contents($localfile, $data);
     $au = new AudioInfo();
     $info = $au->Info($localfile);
     if (isset($info['error'])) {
         echo "Error reading audio info: " . print_r($info['error']) . "\r\n";
     }
     $this->audioLength = $info["playing_time"];
     //echo ("<br>Audio Length: " . $this->audioLength . "<br>");
     //Splice audio into lengths determined by $imageLengthArray
     // Save audio to tmp file
     // Return path to text file contianing audio paths
     $audioTxt .= $localfile . "\r\n";
     $outputAudioTxtFile = $outputPath . "audio.txt";
     $this->writeToFile($outputAudioTxtFile, $audioTxt);
     //Return file path to text file with all created images
     return $outputAudioTxtFile;
 }
Ejemplo n.º 3
0
        $flac = new Zend_Media_Flac($currentpath);
        if ($flac->hasMetadataBlock(Zend_Media_Flac::PICTURE)) {
        // debug
        runelog("coverart match: embedded (ZendMedia lib)");
        header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
        header('Pragma: no-cache'); // HTTP 1.0.
        header('Expires: 0'); // Proxies.
        header('Content-Type: '.$flac->getPicture()->getMimeType());
        echo $flac->getPicture()->getData();
        $output = 1;
        }
    } */
 //Extract info from current audio file (using GetID3 library)
 if ($output === 0) {
     $au = new AudioInfo();
     $auinfo = $au->Info($currentpath);
     // 1. try to find embedded coverart
     if (!empty($auinfo['comments']['picture'][0]['data'])) {
         // debug
         runelog("coverart match: embedded (GetID3 lib)");
         header('Cache-Control: no-cache, no-store, must-revalidate');
         // HTTP 1.1.
         header('Pragma: no-cache');
         // HTTP 1.0.
         header('Expires: 0');
         // Proxies.
         header('Content-Type: ' . $auinfo['comments']['picture'][0]['image_mime']);
         echo $auinfo['comments']['picture'][0]['data'];
         $output = 1;
     }
 }