Search in sources :

Example 1 with ID3v23Tag

use of com.frostwire.mp3.ID3v23Tag in project frostwire by frostwire.

the class SoundcloudDownload method setAlbumArt.

private static boolean setAlbumArt(SoundcloudSearchResult sr, byte[] cover, String inPath, String outPath) {
    try {
        Mp3File mp3 = new Mp3File(inPath);
        ID3Wrapper newId3Wrapper = new ID3Wrapper(new ID3v1Tag(), new ID3v23Tag());
        newId3Wrapper.setAlbum(sr.getUsername() + ": " + sr.getDisplayName() + " via SoundCloud.com");
        newId3Wrapper.setArtist(sr.getUsername());
        newId3Wrapper.setTitle(sr.getDisplayName());
        newId3Wrapper.setAlbumImage(cover, "image/jpg");
        newId3Wrapper.setUrl(sr.getDetailsUrl());
        newId3Wrapper.getId3v2Tag().setPadding(true);
        mp3.setId3v1Tag(newId3Wrapper.getId3v1Tag());
        mp3.setId3v2Tag(newId3Wrapper.getId3v2Tag());
        mp3.save(outPath);
        return true;
    } catch (Throwable e) {
        LOG.error("Error setting art information for soundcloud download", e);
        return false;
    }
}
Also used : Mp3File(com.frostwire.mp3.Mp3File) ID3Wrapper(com.frostwire.mp3.ID3Wrapper) ID3v1Tag(com.frostwire.mp3.ID3v1Tag) ID3v23Tag(com.frostwire.mp3.ID3v23Tag)

Example 2 with ID3v23Tag

use of com.frostwire.mp3.ID3v23Tag in project MusicDNA by harjot-oberai.

the class ID3Chunk method readChunk.

@Override
public boolean readChunk() throws IOException {
    // TODO Auto-generated method stub
    if (!isId3v2Tag()) {
        // Bad ID3V2 tag
        return false;
    }
    int version = raf.read();
    AbstractID3v2Tag id3Tag;
    switch(version) {
        case 2:
            id3Tag = new ID3v22Tag();
            AudioFile.logger.finest("Reading ID3V2.2 tag");
            break;
        case 3:
            id3Tag = new ID3v23Tag();
            AudioFile.logger.finest("Reading ID3V2.3 tag");
            break;
        case 4:
            id3Tag = new ID3v24Tag();
            AudioFile.logger.finest("Reading ID3V2.4 tag");
            break;
        default:
            // bad or unknown version    
            return false;
    }
    aiffTag.setID3Tag(id3Tag);
    // back up to start of tag
    raf.seek(raf.getFilePointer() - 4);
    byte[] buf = new byte[(int) bytesLeft];
    raf.read(buf);
    ByteBuffer bb = ByteBuffer.allocate((int) bytesLeft);
    bb.put(buf);
    try {
        id3Tag.read(bb);
    } catch (TagException e) {
        AudioFile.logger.info("Exception reading ID3 tag: " + e.getClass().getName() + ": " + e.getMessage());
        return false;
    }
    return true;
}
Also used : TagException(org.jaudiotagger.tag.TagException) AbstractID3v2Tag(org.jaudiotagger.tag.id3.AbstractID3v2Tag) ID3v22Tag(org.jaudiotagger.tag.id3.ID3v22Tag) ID3v24Tag(org.jaudiotagger.tag.id3.ID3v24Tag) ID3v23Tag(org.jaudiotagger.tag.id3.ID3v23Tag) ByteBuffer(java.nio.ByteBuffer)

Example 3 with ID3v23Tag

use of com.frostwire.mp3.ID3v23Tag in project frostwire by frostwire.

the class SoundcloudDownload method setAlbumArt.

private boolean setAlbumArt(String mp3Filename, String mp3outputFilename) {
    try {
        byte[] imageBytes = HttpClientFactory.getInstance(HttpClientFactory.HttpContext.DOWNLOAD).getBytes(sr.getThumbnailUrl());
        Mp3File mp3 = new Mp3File(mp3Filename);
        ID3Wrapper newId3Wrapper = new ID3Wrapper(new ID3v1Tag(), new ID3v23Tag());
        newId3Wrapper.setAlbum(sr.getUsername() + ": " + sr.getDisplayName() + " via SoundCloud.com");
        newId3Wrapper.setArtist(sr.getUsername());
        newId3Wrapper.setTitle(sr.getDisplayName());
        newId3Wrapper.setAlbumImage(imageBytes, "image/jpg");
        newId3Wrapper.setUrl(sr.getDetailsUrl());
        newId3Wrapper.getId3v2Tag().setPadding(true);
        mp3.setId3v1Tag(newId3Wrapper.getId3v1Tag());
        mp3.setId3v2Tag(newId3Wrapper.getId3v2Tag());
        mp3.save(mp3outputFilename);
        return true;
    } catch (Throwable e) {
        return false;
    }
}
Also used : Mp3File(com.frostwire.mp3.Mp3File) ID3Wrapper(com.frostwire.mp3.ID3Wrapper) ID3v1Tag(com.frostwire.mp3.ID3v1Tag) ID3v23Tag(com.frostwire.mp3.ID3v23Tag)

Aggregations

ID3Wrapper (com.frostwire.mp3.ID3Wrapper)2 ID3v1Tag (com.frostwire.mp3.ID3v1Tag)2 ID3v23Tag (com.frostwire.mp3.ID3v23Tag)2 Mp3File (com.frostwire.mp3.Mp3File)2 ByteBuffer (java.nio.ByteBuffer)1 TagException (org.jaudiotagger.tag.TagException)1 AbstractID3v2Tag (org.jaudiotagger.tag.id3.AbstractID3v2Tag)1 ID3v22Tag (org.jaudiotagger.tag.id3.ID3v22Tag)1 ID3v23Tag (org.jaudiotagger.tag.id3.ID3v23Tag)1 ID3v24Tag (org.jaudiotagger.tag.id3.ID3v24Tag)1