Android Open Source - music-tag Id3 Tag






From Project

Back to project page music-tag.

License

The source code is released under:

Apache License

If you think the Android project music-tag listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package binauld.pierre.musictag.tag;
/*from  ww  w.  j  a  v a2s.co m*/
import android.util.Log;

import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.tag.FieldDataInvalidException;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;

import java.util.HashMap;
import java.util.Map;

/**
 * Represent a bundle of id3 tag supported by the app.
 */
public abstract class Id3Tag {

    protected HashMap<SupportedTag, String> tags = new HashMap<>();

    public Id3Tag() {
    }

    public Id3Tag(AudioFile audioFile) {
        Tag audioFileTags = audioFile.getTag();
        for(Map.Entry<SupportedTag, FieldKey> entry : SupportedTag.getSupportedTags().entrySet()) {
            tags.put(entry.getKey(), audioFileTags.getFirst(entry.getValue()));
        }
    }

    /**
     * Get the value of a supported tag.
     * @param tag A supported tag.
     * @return The value of the tag.
     */
    public String get(SupportedTag tag){
        return tags.get(tag);
    }

    /**
     * Put the value of a supported tag.
     * @param tag A supported tag.
     * @param value The value of the tag.
     */
    public void put(SupportedTag tag, String value) {
        tags.put(tag, value);
    }

    /**
     * Save the bundle of tag into an audioFile.
     * @param audioFile The audio to save the tag in.
     */
    public void saveInto(AudioFile audioFile) {
        Tag audioFileTag = audioFile.getTag();
        HashMap<SupportedTag, FieldKey> supportedTags = SupportedTag.getSupportedTags();

        for(Map.Entry<SupportedTag, String> entry : tags.entrySet()) {
            try {
                audioFileTag.setField(supportedTags.get(entry.getKey()), entry.getValue());
            } catch (FieldDataInvalidException e) {
                Log.w(this.getClass().toString(), e.getMessage(), e);
            }
        }
    }
}




Java Source Code List

binauld.pierre.musictag.ApplicationTest.java
binauld.pierre.musictag.activities.MainActivity.java
binauld.pierre.musictag.activities.SettingsActivity.java
binauld.pierre.musictag.activities.TagFormActivity.java
binauld.pierre.musictag.activities.TagSuggestionActivity.java
binauld.pierre.musictag.adapter.LibraryItemAdapter.java
binauld.pierre.musictag.adapter.SuggestionItemAdapter.java
binauld.pierre.musictag.adapter.SuggestionViewHolder.java
binauld.pierre.musictag.collection.LibraryItemComparator.java
binauld.pierre.musictag.collection.MultipleBufferedList.java
binauld.pierre.musictag.decoder.AudioFileBitmapDecoder.java
binauld.pierre.musictag.decoder.BitmapDecoder.java
binauld.pierre.musictag.decoder.ResourceBitmapDecoder.java
binauld.pierre.musictag.factory.FileFilterFactory.java
binauld.pierre.musictag.factory.LibraryItemFactory.java
binauld.pierre.musictag.fragments.SettingsFragment.java
binauld.pierre.musictag.helper.LibraryItemFactoryHelper.java
binauld.pierre.musictag.helper.LoaderHelper.java
binauld.pierre.musictag.io.ArtworkLoader.java
binauld.pierre.musictag.io.AsyncDrawable.java
binauld.pierre.musictag.io.DefaultArtworkLoader.java
binauld.pierre.musictag.io.LibraryItemLoaderManager.java
binauld.pierre.musictag.io.LibraryItemLoader.java
binauld.pierre.musictag.io.SuggestionLoader.java
binauld.pierre.musictag.item.AudioItem.java
binauld.pierre.musictag.item.ChildItem.java
binauld.pierre.musictag.item.FolderItem.java
binauld.pierre.musictag.item.LibraryItem.java
binauld.pierre.musictag.item.LoadingState.java
binauld.pierre.musictag.item.NodeItem.java
binauld.pierre.musictag.item.SuggestionItem.java
binauld.pierre.musictag.service.ArtworkService.java
binauld.pierre.musictag.service.CacheService.java
binauld.pierre.musictag.service.Locator.java
binauld.pierre.musictag.tag.Id3TagParcelable.java
binauld.pierre.musictag.tag.Id3Tag.java
binauld.pierre.musictag.tag.SupportedTag.java
binauld.pierre.musictag.widget.AnimatedProgressBar.java