Writing ID3v2 tags to. mp3 files using getID3
Directory
- Writing ID3v2 tags to mp3 files using getID3
-
- Directory
- Brief introduction
- ID3 Label
- Description
- Implementation code
- Information read after successful operation
Brief introduction
A recent project needs to implement a txxx label that writes the handwriting records of the canvas artboard to the ID3v2 in mp3
-GetID3 Official website
-Id3-wikipedia
ID3 Label
ID3, typically located in a number of bytes at the beginning or end of a MP3 file, is appended with information about the MP3 's singer, title, album name, age, style, and so on, which is known as ID3 information, ID3 information is divided into two versions, V1 and V2 editions. Where: V1 version of the ID3 at the end of the MP3 file 128 bytes, starting with the tag three characters, followed by the song information. V2 version is generally located at the beginning of MP3, can store lyrics, the album's Pictures and other large-capacity information. --[Baidu Encyclopedia]
Description
> 笔迹标签为具有一定长度的字符串,而TXXX标签就是用来保存文本数据
Implementation code
Write handwriting data to the. mp3 file:
require_once('./getid3/write.id3v2.php ');$tagwriter=NewGetid3_write_id3v2;//file path$tagwriter->filename ='./test.mp3 ';//label content$TagData=Array(' TXXX '=Array(Array(' Encodingid '=1,' description '=' TXXX ',' Data '=' handwriting data ')) );$tagwriter->tag_data =$TagData;//Using the Writeid3v2 method to writeif($tagwriter->writeid3v2 ()) {Echo' successfully wrote tags
';if(!Empty($tagwriter->warnings)) {Echo' There were some warnings:
'. Implode ('
',$tagwriter->warnings); } }Else{Echo' Failed to write tags!
'. Implode ('<>
'
,$tagwriter->errors); }
Read the. mp3 file Txxx Tags:
require_once('./getid3/getid3.php');$filename'./test.mp3';$getID3new getID3;$ThisFileInfo$getID3->analyze($filename);$map['filename']=$ThisFileInfo['filename'];$map['TXXX']=$ThisFileInfo['id3v2']['TXXX'][0]['data'];exit(json_encode($map));
Information read after successful operation
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the use of getID3 to MP3 files to write ID3v2 tags, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.