本文整理汇总了PHP中getid3_id3v1::cutfield方法的典型用法代码示例。如果您正苦于以下问题:PHP getid3_id3v1::cutfield方法的具体用法?PHP getid3_id3v1::cutfield怎么用?PHP getid3_id3v1::cutfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类getid3_id3v1
的用法示例。
在下文中一共展示了getid3_id3v1::cutfield方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Analyze
public function Analyze()
{
$getid3 = $this->getid3;
fseek($getid3->fp, -256, SEEK_END);
$pre_id3v1 = fread($getid3->fp, 128);
$id3v1_tag = fread($getid3->fp, 128);
if (substr($id3v1_tag, 0, 3) == 'TAG') {
$getid3->info['avdataend'] -= 128;
// Shortcut
$getid3->info['id3v1'] = array();
$info_id3v1 =& $getid3->info['id3v1'];
$info_id3v1['title'] = getid3_id3v1::cutfield(substr($id3v1_tag, 3, 30));
$info_id3v1['artist'] = getid3_id3v1::cutfield(substr($id3v1_tag, 33, 30));
$info_id3v1['album'] = getid3_id3v1::cutfield(substr($id3v1_tag, 63, 30));
$info_id3v1['year'] = getid3_id3v1::cutfield(substr($id3v1_tag, 93, 4));
$info_id3v1['comment'] = substr($id3v1_tag, 97, 30);
// can't remove nulls yet, track detection depends on them
$info_id3v1['genreid'] = ord(substr($id3v1_tag, 127, 1));
// If second-last byte of comment field is null and last byte of comment field is non-null then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
if ($id3v1_tag[125] === "" && $id3v1_tag[126] !== "") {
$info_id3v1['track'] = ord(substr($info_id3v1['comment'], 29, 1));
$info_id3v1['comment'] = substr($info_id3v1['comment'], 0, 28);
}
$info_id3v1['comment'] = getid3_id3v1::cutfield($info_id3v1['comment']);
$info_id3v1['genre'] = getid3_id3v1::LookupGenreName($info_id3v1['genreid']);
if (!empty($info_id3v1['genre'])) {
unset($info_id3v1['genreid']);
}
if (empty($info_id3v1['genre']) || @$info_id3v1['genre'] == 'Unknown') {
unset($info_id3v1['genre']);
}
foreach ($info_id3v1 as $key => $value) {
$key != 'comments' and $info_id3v1['comments'][$key][0] = $value;
}
$info_id3v1['tag_offset_end'] = filesize($getid3->filename);
$info_id3v1['tag_offset_start'] = $info_id3v1['tag_offset_end'] - 128;
}
if (substr($pre_id3v1, 0, 3) == 'TAG') {
// The way iTunes handles tags is, well, brain-damaged.
// It completely ignores v1 if ID3v2 is present.
// This goes as far as adding a new v1 tag *even if there already is one*
// A suspected double-ID3v1 tag has been detected, but it could be that the "TAG" identifier is a legitimate part of an APE or Lyrics3 tag
if (substr($pre_id3v1, 96, 8) == 'APETAGEX') {
// an APE tag footer was found before the last ID3v1, assume false "TAG" synch
} elseif (substr($pre_id3v1, 119, 6) == 'LYRICS') {
// a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch
} else {
// APE and Lyrics3 footers not found - assume double ID3v1
$getid3->warning('Duplicate ID3v1 tag detected - this has been known to happen with iTunes.');
$getid3->info['avdataend'] -= 128;
}
}
return true;
}