function _getFileInfo($file, $realPath = false) { $r = array(); $r['path'] = $file; //TODO: this is it's real path, get it's vfs path? $f = ($realPath ? "" : $this->_basePath()) . $file; $r['name'] = basename($f); $r["size"] = $this->_getSize($f); if (is_dir($f)) { $r["type"] = "text/directory"; } else { if (is_file($f)) { $r["modified"] = date("F d Y H:i:s.", filemtime($f)); $r["type"] = mime_content_type($f); if ($r["type"] == false) { $r["type"] = mime_content_type_alt($f); } } } //get ID3 info if available if (function_exists("id3_get_tag")) { $id3 = id3_get_tag($f); foreach ($id3 as $key => $value) { $r["id3" . str_replace(" ", "", ucwords($key))] = $value; } } return $r; }
/** * Returns the information we could find on the file * @return Array */ public function getFileinfo() { $toret = parent::getFileinfo(); // get the ID3 data if it is an MP3 if ($this->extension == 'MP3') { if (function_exists('id3_get_tag')) { try { $id3sata = id3_get_tag($this->fullpath); foreach ($id3sata as $key => $val) { if ($key == 'genre') { $toret['mp3.' . $key] = id3_get_genre_name($val); } else { $toret['mp3.' . $key] = $val; } } } catch (Exception $e) { } } } return $toret; }
<?php $tag_found = "../audio_temp/test/11_Interlude_Holiday.mp3"; $tag = id3_get_tag($tag_found); print_r($tag);
<?php use Jasny\Audio\Track; require_once '../src/Jasny/Audio/Track.php'; $track = new Track("tracks/" . (isset($_GET['track']) ? $_GET['track'] : 'demo.wav')); $id3 = function_exists('id3_get_tag') ? id3_get_tag((string) $track) : array(); $result = $id3 + (array) $track->getAnnotations(true) + (array) $track->getStats(); header('Content-Type: application/json'); echo json_encode($result);
<?php include '_header.php'; ?> <a target="_blank" href="http://php.net/manual/en/function.id3-get-tag.php">Read this.</a> <?php $tag = id3_get_tag("/var/www/music.77dogwood.us/html/VA-Straight_Up_Glitch_Hop_Vol_10-WEB-2015-iHR/14-katori-hello_(feat._caitlin_cardier)_(den5ity_remix).mp3"); print_r($tag); ?> <?php include '_footer.php';