Skip to end of metadata
Go to start of metadata
Contents Summary
 

The source code in below examples uses some methods defined in Working with Common Utilities

Working with ID3v2 Tag

Reading ID3v2 Tag

GroupDocs.Metadata API also supports reading ID3v2 (ID3v2.3 and ID3v2.4) Tag in MP3 format. As ID3v2.2 is obsolete by ID3.org, therefore it is not supported by GroupDocs.Metadata API. To get more information about ID3 tags, visit: https://en.wikipedia.org/wiki/ID3

Following are the steps to read ID3v2 tag in MP3 format.

  1. Initialize Mp3Format
  2. Get ID3v2 tag using mp3Format.getId3v2() property
  3. If ID3v2 tag is not Null and present then check for all of its properties

Reading ID3v2 Tag Using Stream

You can also read ID3v2 Tag using a stream. Following are the steps to read the ID3v2 tag in MP3 format.

  1. Initialize stream using InputStream stream = new FileInputStream(Common.mapSourceFilePath(filepath))
  2. Initialize Mp3Format
  3. Get ID3v2 tag using Mp3Format.getId3v2Properties() property
  4. If ID3v2 tag is not Null and present then check for all of its properties

 

Updating ID3v2 Tag

Following are the steps to update ID3v2 tag in Mp3 format.

  1. Initialize Mp3Format
  2. Create Id3v2Tag object
  3. Update properties i-e Id3v2Tag.setArtist()
  4. Update metadata in Mp3Format object using Mp3Format.updateId3v2(Id3v2Tag)
  5. Save metadata using Mp3Format.save()

Following code snippet shows how to update ID3v2 tag in MP3 format.

Updating ID3V2 Tag Using Stream

 You can also update ID3v3 tag using Stream. Following are the steps to update ID3v2 tag in Mp3 format.

  1. Initialize Stream using OutputStream stream = new FileOutputStream(Common.mapDestinationFilePath(filepath))
  2. Initialize Mp3Format
  3. Create Id3v2Tag object
  4. Update properties i-e Id3v2Tag.setArtist("Ali")
  5. Update metadata in Mp3Format object using Mp3Format.updateId3v2(Id3v2Tag)
  6. Save metadata using Mp3Format.save(OutputStream)

Following code snippet shows how to update ID3v2 tag in MP3 format.

Removing ID3v2 Tag

Following are the steps to remove ID3v2 tag in Mp3 format.

  1. Initialize Mp3Format class
  2. Remove ID3V2 Tag
  3. Save metadata using Mp3Format.save()

Following code snippet shows how to remove ID3v2 tag in MP3 format:

This feature is supported by version 18.2 or greater.

Reading Additional Properties 

GroupDocs.Metadata API allows you to read additional metadata properties linked with ID3v2 tag. Following are the new properties you can read from ID3v2 metadata:

  • Subtitle (TIT3 frame)
  • MusicalKey (TKEY frame)
  • LengthInMilliseconds (TLEN frame)
  • OriginalAlbum (TOAL frame)
  • SizeInBytes (TSIZ frame)
  • ISRC (TSRC frame)
  • SoftwareHardware (TSSE frame)
  • PlayCounter (PCNT frame)

Following are the steps to read additional properties from the ID3v2 tag in MP3 format.

  1. Initialize Mp3Format
  2. Get ID3v2 tag using mp3Format.getId3v2() property
  3. If ID3v2 tag is not Null and present then check for all of its properties

 

This feature is supported by version 18.2 or greater.

Reading Image Cover from ID3v2 

GroupDocs.Metadata API allows you to read image cover data from the ID3v2 tag in MP3 Format. 

Following are the steps to read image cover from the ID3v2 tag in MP3 format.

  1. Initialize Mp3Format
  2. Get ID3v2 tag using Mp3Format.getId3v2Tag() property
  3. If ID3v2 tag is not Null, read APIC frames
  4. If frames are not Null, get AttachedPictureFrame 

 

This feature is supported by version 18.2 or greater.

Updating or Removing Image Cover from ID3v2 

GroupDocs.Metadata API allows you to update or remove image cover data from the ID3v2 tag in MP3 Format. 

Following are the steps to update or remove image cover from the ID3v2 tag in MP3 format.

  1. Initialize Mp3Format
  2. Get ID3v2 tag using Mp3Format.getId3v2Tag() property
  3. Remove image cover using Id3v2Tag.removeImageCover()
  4. Update image cover using Mp3Format.updateID3v2(Id3v2Tag)

 

This feature is supported by version 18.2 or greater.

Updating ID3V2 Tag Using Properties

GroupDocs.Metadata API provides you with an easy way to update ID3v2 metadata in Mp3Format. Library updates ID3v2 if specific properties were changed in user code. Otherwise, the update will not happen.

  1. Initialize Mp3Format
  2. Create Id3v2Tag object
  3. Update properties i-e Id3v2Tag.setArtist()
  4. Save metadata using Mp3Format.save()

Following code snippet shows how to update ID3v2 tag in MP3 format.

Labels
  • No labels