当前位置: 首页>>代码示例>>PHP>>正文


PHP getid3_id3v1::cutfield方法代码示例

本文整理汇总了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;
 }
开发者ID:ryumaru,项目名称:ryuzinewriter,代码行数:54,代码来源:module.tag.id3v1.php


注:本文中的getid3_id3v1::cutfield方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。