本文整理匯總了PHP中getid3_lib類的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib類的具體用法?PHP getid3_lib怎麽用?PHP getid3_lib使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了getid3_lib類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tag_mp3
function tag_mp3($filename, $songname, $albumname, $artist, $time)
{
$TaggingFormat = 'UTF-8';
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => $TaggingFormat));
getid3_lib::IncludeDependency('/var/www/html/getid3/getid3/write.php', __FILE__, true);
// Initialize getID3 tag-writing module
$tagwriter = new getid3_writetags();
$tagwriter->filename = $filename;
$tagwriter->tagformats = array('id3v1', 'id3v2.3');
// set various options (optional)
$tagwriter->overwrite_tags = true;
$tagwriter->tag_encoding = $TaggingFormat;
$tagwriter->remove_other_tags = true;
// populate data array
$TagData['title'][] = $songname;
$TagData['artist'][] = $artist;
$TagData['album'][] = $albumname;
$tagwriter->tag_data = $TagData;
// write tags
if ($tagwriter->WriteTags()) {
echo 'Successfully wrote tags<br>';
if (!empty($tagwriter->warnings)) {
echo 'There were some warnings:<br>' . implode('<br><br>', $tagwriter->warnings);
}
} else {
echo 'Failed to write tags!<br>' . implode('<br><br>', $tagwriter->errors);
}
}
示例2: add
function add($item)
{
global $config;
if ($item['url']) {
// this is a remote file
if ($config['httpStreaming']) {
$lines = file($item['url']);
foreach ($lines as $line) {
if (!empty($line)) {
$this->audioFiles[] = array('url' => $line);
}
}
} else {
// nothing to do
// not tested for Tamburine
}
} else {
// this is a local file
// CHANGED BY BUDDHAFLY 06-02-20
if (!in_array(sotf_File::getExtension($item['path']), $config['skipGetID3FileTypes'])) {
$getID3 = new getID3();
$mp3info = $getID3->analyze($item['path']);
getid3_lib::CopyTagsToComments($mp3info);
} else {
$fileinfo['video'] = true;
}
//$mp3info = GetAllFileInfo($item['path']);
//debug('mp3info', $mp3info);
// CHANGED BY BUDDHAFLY 06-02-20
$bitrate = (string) $mp3info['bitrate'];
if (!$bitrate) {
raiseError("Could not determine bitrate, maybe this audio is temporarily unavailable");
}
$item['bitrate'] = $bitrate;
if ($config['httpStreaming']) {
//$tmpFileName = 'au_' . $item['id'] . '_' . ($item['name'] ? $item['name'] : basename($item['path']));
$tmpFileName = 'au_' . $item['id'] . '_' . basename($item['path']);
$tmpFile = $config['tmpDir'] . "/{$tmpFileName}";
$file = @readlink($tmpFile);
if ($file) {
if (!is_readable($file)) {
logError("Bad symlink: {$tmpFile} to {$file}");
unlink($tmpFile);
$file = false;
}
}
if (!$file) {
if (!symlink($item['path'], $tmpFile)) {
raiseError("symlink failed in tmp dir");
}
}
$item['url'] = $config['tmpUrl'] . "/{$tmpFileName}";
}
$this->totalLength += $mp3info["playtime_seconds"];
$this->audioFiles[] = $item;
}
}
示例3: extractDataFromFilename
protected function extractDataFromFilename($filename)
{
if (empty($filename)) {
return null;
}
$id3 = new getID3();
$data = $id3->analyze($filename);
getid3_lib::CopyTagsToComments($data);
return $data;
}
示例4: sotf_AudioFile
/**
* Sets up sotf_AudioFile object
*
* @constructor sotf_AudioFile
* @param string $path Path of the file
*/
function sotf_AudioFile($path)
{
$parent = get_parent_class($this);
parent::$parent($path);
// Call the constructor of the parent class. lk. super()
// CHANGED BY BUDDHAFLY 06-05-12
$getID3 = new getID3();
$fileinfo = $getID3->analyze($this->path);
getid3_lib::CopyTagsToComments($fileinfo);
//$fileinfo = GetAllFileInfo($this->path);
$this->allInfo = $fileInfo;
//if ($audioinfo["fileformat"] == 'mp3' || $audioinfo["fileformat"] == 'ogg') {
//debug("finfo", $fileinfo);
if (isset($fileinfo['audio'])) {
$audioinfo = $fileinfo['audio'];
$this->type = "audio";
$this->format = $fileinfo["fileformat"];
if ($audioinfo["bitrate_mode"] == 'vbr') {
$this->bitrate = "VBR";
}
$this->bitrate = round($audioinfo["bitrate"] / 1000);
$this->average_bitrate = round($audioinfo["bitrate"] / 1000);
$this->samplerate = $audioinfo["sample_rate"];
$this->channels = $audioinfo["channels"];
$this->duration = round($fileinfo["playtime_seconds"]);
$this->mimetype = $this->determineMimeType($this->format);
}
}
示例5: getId3Data
/**
*
*
* @return array
*/
public function getId3Data() : array
{
$reader = new \getID3();
$info = $reader->analyze($this->path);
\getid3_lib::CopyTagsToComments($info);
return $info;
}
示例6: import_show
function import_show($showid, $dir, $type)
{
// Initialize getID3 engine
$getID3 = new getID3();
// Read files and directories
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$full_name = $dir . "/" . $file;
if (is_file($full_name) || $file[0] != '.') {
$ThisFileInfo = $getID3->analyze($full_name);
if ($ThisFileInfo['fileformat'] == "mp3") {
getid3_lib::CopyTagsToComments($ThisFileInfo);
$album = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['album']));
$play_time = mysql_real_escape_string(@$ThisFileInfo['playtime_seconds']);
$title_name = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['title']));
$artist_name = mysql_real_escape_string(@implode(@$ThisFileInfo['comments_html']['artist']));
$full_name = mysql_real_escape_string($full_name);
if ($id = song_non_existant($full_name, $showid)) {
$artist_id = check_or_insert_artist($artist_name);
insert_into_tunes($title_name, $artist_id, $full_name, $album, $play_time, $showid, -1, $type);
} else {
$artist_id = check_or_insert_artist($artist_name);
update_tunes($title_name, $id, $artist_id, $full_name, $album, $play_time);
}
}
}
}
closedir($dh);
}
}
}
示例7: getId3
/**
* Get ID3 Details
*
* @param string $path
*
* @return array
*/
protected function getId3($path)
{
$getID3 = new \getID3();
$analyze = $getID3->analyze($path);
\getid3_lib::CopyTagsToComments($analyze);
return $analyze;
}
示例8: readMetadata
public static function readMetadata($file)
{
require_once __DIR__ . '/../vendor/autoload.php';
$getID3 = new \getID3();
$meta = $getID3->analyze($file);
\getid3_lib::CopyTagsToComments($meta);
return $meta;
}
示例9: getID3
public function getID3()
{
require_once PHPWS_SOURCE_DIR . 'lib/vendor/autoload.php';
$getID3 = new getID3();
// File to get info from
$file_location = $this->getPath();
// Get information from the file
$fileinfo = $getID3->analyze($file_location);
getid3_lib::CopyTagsToComments($fileinfo);
return $fileinfo;
}
示例10: Info
/**
* Extract information - only public function
*
* @access public
* @param string file Audio file to extract info from.
*/
function Info($file)
{
// Analyze file
$this->info = $this->getID3->analyze($file);
// Exit here on error
if (isset($this->info['error'])) {
return array('error' => $this->info['error']);
} else {
getid3_lib::CopyTagsToComments($this->info);
}
// Init wrapper object
$this->result = array();
$this->result['format_name'] = (isset($this->info['fileformat']) ? $this->info['fileformat'] : '') . '/' . (isset($this->info['audio']['dataformat']) ? $this->info['audio']['dataformat'] : '') . (isset($this->info['video']['dataformat']) ? '/' . $this->info['video']['dataformat'] : '');
$this->result['encoder_version'] = isset($this->info['audio']['encoder']) ? $this->info['audio']['encoder'] : '';
$this->result['encoder_options'] = isset($this->info['audio']['encoder_options']) ? $this->info['audio']['encoder_options'] : '';
$this->result['bitrate_mode'] = isset($this->info['audio']['bitrate_mode']) ? $this->info['audio']['bitrate_mode'] : '';
$this->result['channels'] = isset($this->info['audio']['channels']) ? $this->info['audio']['channels'] : '';
$this->result['sample_rate'] = isset($this->info['audio']['sample_rate']) ? $this->info['audio']['sample_rate'] : '';
$this->result['bits_per_sample'] = isset($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : '';
$this->result['playing_time'] = isset($this->info['playtime_seconds']) ? $this->info['playtime_seconds'] : '';
$this->result['playtime_string'] = isset($this->info['playtime_string']) ? $this->info['playtime_string'] : '';
$this->result['avg_bit_rate'] = isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : '';
$this->result['tags'] = isset($this->info['tags']) ? $this->info['tags'] : '';
$this->result['comments'] = isset($this->info['comments']) ? $this->info['comments'] : '';
$this->result['warning'] = isset($this->info['warning']) ? $this->info['warning'] : '';
$this->result['md5'] = isset($this->info['md5_data']) ? $this->info['md5_data'] : '';
// Post getID3() data handling based on file format
$method = (isset($this->info['fileformat']) ? $this->info['fileformat'] : '') . 'Info';
if ($method && method_exists($this, $method)) {
$this->{$method}();
}
return $this->result;
}
示例11: readFileDirectory
function readFileDirectory($path)
{
global $mysql, $getID3, $albumSongs;
foreach (scandir($path) as $currentFile) {
if ($currentFile == "." || $currentFile == "..") {
continue;
}
$fullPath = $path . "/" . $currentFile;
if (is_dir($fullPath)) {
readFileDirectory($fullPath);
} else {
$fileExtension = pathinfo($currentFile, PATHINFO_EXTENSION);
if ($fileExtension == "mp3" || $fileExtension == "wav" || $fileExtension == "ogg") {
$songInfo = $getID3->analyze($fullPath);
getid3_lib::CopyTagsToComments($songInfo);
if (!$songInfo['comments_html']['title'][0]) {
$songInfo['comments_html']['title'][0] = basename($currentFile);
}
if ($songInfo['tags']['id3v2']['album'][0]) {
$albumSongs[escape($songInfo['tags']['id3v2']['album'][0])] = true;
} else {
$albumSongs[escape($songInfo['comments_html']['artist'][0])] = true;
}
$mysql->query("INSERT INTO `songs` (`path`, `title`, `artist`, `album`, `length`) VALUES ('{$fullPath}', '" . escape($songInfo['comments_html']['title'][0]) . "', '" . escape($songInfo['comments_html']['artist'][0]) . "', '" . escape($songInfo['tags']['id3v2']['album'][0]) . "', '" . escape($songInfo['playtime_string']) . "')");
}
}
}
}
示例12: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$info['fileformat'] = 'rar';
if ($this->option_use_rar_extension === true) {
if (function_exists('rar_open')) {
if ($rp = rar_open($info['filenamepath'])) {
$info['rar']['files'] = array();
$entries = rar_list($rp);
foreach ($entries as $entry) {
$info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
}
rar_close($rp);
return true;
} else {
$info['error'][] = 'failed to rar_open(' . $info['filename'] . ')';
}
} else {
$info['error'][] = 'RAR support does not appear to be available in this PHP installation';
}
} else {
$info['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
}
return false;
}
示例13: parseSoundFile
public static function parseSoundFile($filename)
{
global $getID3;
// Get sound meta
$id3 = $getID3->analyze($filename);
getid3_lib::CopyTagsToComments($id3);
// Validate
if (!Sounds::validateID3($id3)) {
unlink($filename);
return false;
}
// Make our directory
$artist = @$id3['comments']['artist'][0];
$album = @$id3['comments']['album'][0];
$dir = DOC_ROOT . '/music/' . Sounds::safeDirectory($artist) . '/' . Sounds::safeDirectory($album);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
// Our new filename
$moved = $dir . '/' . basename($filename);
// Already exists! Madness!
if (file_exists($moved)) {
unlink($filename);
return false;
}
// Move
rename($filename, $moved);
// Create and Save
$sound = new Sound(array('filename' => $moved));
$sound->save();
return $sound;
}
示例14: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$DSSheader = fread($this->getid3->fp, 1256);
if (!preg_match('#^(\\x02|\\x03)dss#', $DSSheader)) {
$info['error'][] = 'Expecting "[02-03] 64 73 73" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)) . '"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
// shortcut
$info['dss'] = array();
$thisfile_dss =& $info['dss'];
$info['fileformat'] = 'dss';
$info['audio']['dataformat'] = 'dss';
$info['audio']['bitrate_mode'] = 'cbr';
//$thisfile_dss['encoding'] = 'ISO-8859-1';
$thisfile_dss['version'] = ord(substr($DSSheader, 0, 1));
$thisfile_dss['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$thisfile_dss['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
//$thisfile_dss['length'] = intval(substr($DSSheader, 62, 6)); // I thought time was in seconds, it's actually HHMMSS
$thisfile_dss['length'] = intval(substr($DSSheader, 62, 2) * 3600 + substr($DSSheader, 64, 2) * 60 + substr($DSSheader, 66, 2));
$thisfile_dss['priority'] = ord(substr($DSSheader, 793, 1));
$thisfile_dss['comments'] = trim(substr($DSSheader, 798, 100));
//$info['audio']['bits_per_sample'] = ?;
//$info['audio']['sample_rate'] = ?;
$info['audio']['channels'] = 1;
$info['playtime_seconds'] = $thisfile_dss['length'];
$info['audio']['bitrate'] = $info['filesize'] * 8 / $info['playtime_seconds'];
return true;
}
示例15: getid3_exe
function getid3_exe(&$fd, &$ThisFileInfo)
{
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
$EXEheader = fread($fd, 28);
if (substr($EXEheader, 0, 2) != 'MZ') {
$ThisFileInfo['error'][] = 'Expecting "MZ" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "' . substr($EXEheader, 0, 2) . '" instead.';
return false;
}
$ThisFileInfo['fileformat'] = 'exe';
$ThisFileInfo['exe']['mz']['magic'] = 'MZ';
$ThisFileInfo['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
$ThisFileInfo['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
$ThisFileInfo['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
$ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
$ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
$ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
$ThisFileInfo['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
$ThisFileInfo['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
$ThisFileInfo['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
$ThisFileInfo['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
$ThisFileInfo['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
$ThisFileInfo['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
$ThisFileInfo['exe']['mz']['byte_size'] = ($ThisFileInfo['exe']['mz']['raw']['page_count'] - 1) * 512 + $ThisFileInfo['exe']['mz']['raw']['last_page_size'];
$ThisFileInfo['exe']['mz']['header_size'] = $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] * 16;
$ThisFileInfo['exe']['mz']['memory_minimum'] = $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
$ThisFileInfo['exe']['mz']['memory_recommended'] = $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
$ThisFileInfo['error'][] = 'EXE parsing not enabled in this version of getID3()';
return false;
}