Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get and set (change) ID3 tag (metadata) of audio files?

Tags:

I am working to change ID3 tags, the metadata in audio files, such as:

  • Artist
  • Title
  • Album
  • etc.

And the core point,. that edited ID3 tags should be shown only into my app.

like image 549
Chirag Shah Avatar asked Mar 14 '12 18:03

Chirag Shah


People also ask

How do I change ID3 tags?

Manually edit tag data on your music tracks...Start Music Tag and add some music files. Select a file that you wish to edit. Click inside a tag text field, and make your changes. Click "Save Changes" to apply the updated tag data to your tracks.

How do I get metadata from audio files?

Metadata2Go.com is a free online tool that allows you to access the hidden exif & meta data of your files. Just drag & drop or upload an image, document, video, audio or even e-book file. We will show you all metadata hidden inside the file!

How do I change the tags on a music file?

Tap on the field you wish to edit (title, artist, album, genre or year). Type the desired information in the field. Use the on-screen keyboard to delete or edit the current information, if needed.


1 Answers

I think this is what you are looking for MyID3 library to set and get tags for media file.

Download this jar file MyID3_for_android and add it to your project's build path. here is the sample code. here pathdata is the file path of the audio file.

            File src = new File(pathdata);             MusicMetadataSet src_set = null;             try {                 src_set = new MyID3().read(src);             } catch (IOException e1) {                 // TODO Auto-generated catch block                 e1.printStackTrace();             } // read metadata              if (src_set == null) // perhaps no metadata             {                 Log.i("NULL", "NULL");             }             else             {                 try{                     IMusicMetadata metadata = src_set.getSimplified();                     String artist = metadata.getArtist();                       String album = metadata.getAlbum();                       String song_title = metadata.getSongTitle();                      Number track_number = metadata.getTrackNumber();                      Log.i("artist", artist);                     Log.i("album", album);                 }catch (Exception e) {                     e.printStackTrace();                 }                 File dst = new File(pathdata);                 MusicMetadata meta = new MusicMetadata("name");                 meta.setAlbum("Chirag");                 meta.setArtist("CS");                 try {                     new MyID3().write(src, dst, src_set, meta);                 } catch (UnsupportedEncodingException e) {                     // TODO Auto-generated catch block                     e.printStackTrace();                 } catch (ID3WriteException e) {                     // TODO Auto-generated catch block                     e.printStackTrace();                 } catch (IOException e) {                     // TODO Auto-generated catch block                     e.printStackTrace();                 }  // write updated metadata             } 

Happy Coding :)

like image 175
MKJParekh Avatar answered Nov 01 '22 10:11

MKJParekh