Yangi formatda davom etish uchun: https://uzfor.net/view.php?act=post&id=40156
Postga havola
uDesign [758] [off]
Salom do`stlar demak yana 1 ta foydali ko`d sizlar uchun.
Bu kod mp3 fayl ma`lumotlarini aniqlab beradi.
Yani saytingizdagi mp3 fayl manzilini yozsangiz
mp3 nomi, artis, vaqti, hajmi, album, year, comment, track, genreno, version va hokozo.
CLASS ko`di fayl nomi getMP3info.php
ishlatish kodi
Natija
Bu kod mp3 fayl ma`lumotlarini aniqlab beradi.
Yani saytingizdagi mp3 fayl manzilini yozsangiz
mp3 nomi, artis, vaqti, hajmi, album, year, comment, track, genreno, version va hokozo.
CLASS ko`di fayl nomi getMP3info.php
<?php # getMP3info.php // ===== Получение информации о mp3-файле ====================================== function getMP3data($filename) { $ret['filename'] = $filename; $ret['error'] = 'Error opening file.'; return $ret; } // Определение ID3 тегов if ($s = getID3v1($filename)) { $ret['id3v1'] = $s; } if ($s = getID3v2($filename)) { $ret['id3v2'] = $s; } // Если есть id3v2 тег, то перед поиском mp3 фрейма сдвигаем указатель файла за id3v2 тег // Ищем mp3 фрейм. - 11111111-11111111-1111111? (0xFFF(E)) do { $ret['error'] = 'MP3 frame not found.'; return $ret; } } } while ($header[0] != 1 && $header[1] != 1 && $header[2] != 1) ; // Нашли первый mp3 фрейм. Читаем информацию if ($header[11] == 0) { $ret['id'] == 'MPEG-2.5'; } else { if ($header[12] == 1) { $ret['id'] = 'MPEG-1'; } else { $ret['id'] = 'MPEG-2'; } } ); $ret['layer'] = $layers[$header[13]][$header[14]]; if ($header[15] == 0) {$ret['protect_CRC'] = true; } ); ); 1 => array(0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0),// MPEG-2.5 Layer I ); $ret['bitrate'] = $bitrates[$ret['id']][$ret['layer']][bindec($header[16].$header[17].$header[18].$header[19])]; ), ), ), ); $ret['frequency'] = $frequency[$ret['id']][$header[20]][$header[21]]; $ret['padding'] = $header[22]; ); ); $ret['mode'] = $modes[$header[24]][$header[25]]; // Если режим = Joint Stereo if ($header[24] == 0 && $header[25] == 1) { $ret['Intensity stereo'] = $header[26]; $ret['MS stereo'] = $header[27]; } $ret['Copyrighted'] = $header[28]; $ret['Original'] = $header[29]; ); $ret['Emphasis'] = $emphasises[$header[30]][$header[31]]; // ============================================================================= if ($ret['Mode'] != 'Mono' && $ret['id'] == 'MPEG-1') { $offset = 32; } else if ($ret['Mode'] == 'Mono' && $ret['id'] == 'MPEG-1') { $offset = 17; } else if ($ret['Mode'] == 'Mono' && ($ret['id'] == 'MPEG-2' || $ret['id'] == 'MPEG-2.5')) { $offset = 9; } else { $offset = 17; } $ret['bitrate_mode'] = 'VBR'; $ret['VBR_header'] = 'VBRI'; $ret['nof'] = $numberOfFrames; $duration = floor($numberOfFrames * $samplesPerFrame[$ret['id']][$ret['layer']] / $ret['frequency']); } else $ret['bitrate_mode'] = 'VBR'; $ret['VBR_header'] = 'Xing'; $duration = floor($numberOfFrames * $samplesPerFrame[$ret['id']][$ret['layer']] / $ret['frequency']); } else { $ret['bitrate_mode'] = 'CBR'; if ($ret['id3v1']) { $datasize -= 128; } if ($ret['id3v2']) { $datasize -= $ret['id3v2']['size'] - 10; } } $ret['diration']= (int)$duration; return $ret; } // ===== Получение информации о ID3v2 тегах ==================================== function getID3v2($filename) { $ret['error'] = 'Error opening file.'; return $ret; } if ($header['signature'] != 'ID3') { return false; } $ret['version'] = $header['version_major']. '.' .$header['version_minor']; return $ret; } // ===== Получение информации о ID3v1 тегах ==================================== function getID3v1($filename) { $ret['error'] = 'Error opening file.'; return $ret; } // ID3v1.1 $format = 'a3tag/a30name/a30artists/a30album/a4year/a28comment/x1/c1track/c1genreno'; } else { // ID3v1.0 $format = 'a3tag/a30name/a30artists/a30album/a4year/a30comment/c1genreno'; } if ($ret['tag'] == 'TAG') { return $ret; } return false; } ?>
ishlatish kodi
<?php include('getMP3info.php'); echo '<pre>'; $info = getMP3data('music.mp3');// mp3 manzili echo '</pre>'; // kerakli joyga pasdagi ko`dni qo`yamiz echo 'Albom: '.$info['id3v1']['album'].'<br>'; echo 'Bitreyt: '.$info['bitrate']; ?>
Natija
Array ( [filename] => music.mp3 [id3v1] => Array ( [tag] => TAG [name] => Rapture (Avicii New Generation [artists] => Nadia Ali [album] => Rapture [year] => 2010 [comment] => [track] => 1 [genreno] => 31 ) [id3v2] => Array ( [version] => 3.0 [size] => 2518 ) [id] => MPEG-1 [layer] => 3 [bitrate] => 320 [frequency] => 44100 [padding] => 0 [mode] => Joint stereo [Intensity stereo] => 0 [MS stereo] => 0 [Copyrighted] => 0 [Original] => 1 [Emphasis] => None [bitrate_mode] => CBR [duration_str] => 03:41 [duration_str_hour] => 00:03:41 [diration] => 221 ) Albom: Rapture Bitreyt: 320