Package org.farng.mp3

Examples of org.farng.mp3.InvalidTagException


     */
    public ID3v2_4Frame(final Lyrics3v2Field field) throws InvalidTagException {
        final String id = field.getIdentifier();
        final String value;
        if (id.equals("IND")) {
            throw new InvalidTagException("Cannot create ID3v2.40 frame from Lyrics3 indications field.");
        } else if (id.equals("LYR")) {
            final FieldBodyLYR lyric = (FieldBodyLYR) field.getBody();
            ObjectLyrics3Line line;
            final Iterator iterator = lyric.iterator();
            final FrameBodySYLT sync;
            final FrameBodyUSLT unsync;
            final boolean hasTimeStamp = lyric.hasTimeStamp();

            // we'll create only one frame here.
            // if there is any timestamp at all, we will create a sync'ed frame.
            sync = new FrameBodySYLT((byte) 0, "ENG", (byte) 2, (byte) 1, "");
            unsync = new FrameBodyUSLT((byte) 0, "ENG", "", "");
            while (iterator.hasNext()) {
                line = (ObjectLyrics3Line) iterator.next();
                if (hasTimeStamp) {
                    sync.addLyric(line);
                } else {
                    unsync.addLyric(line);
                }
            }
            if (hasTimeStamp) {
                this.setBody(sync);
            } else {
                this.setBody(unsync);
            }
        } else if (id.equals("INF")) {
            value = ((FieldBodyINF) field.getBody()).getAdditionalInformation();
            this.setBody(new FrameBodyCOMM((byte) 0, "ENG", "", value));
        } else if (id.equals("AUT")) {
            value = ((FieldBodyAUT) field.getBody()).getAuthor();
            this.setBody(new FrameBodyTCOM((byte) 0, value));
        } else if (id.equals("EAL")) {
            value = ((FieldBodyEAL) field.getBody()).getAlbum();
            this.setBody(new FrameBodyTALB((byte) 0, value));
        } else if (id.equals("EAR")) {
            value = ((FieldBodyEAR) field.getBody()).getArtist();
            this.setBody(new FrameBodyTPE1((byte) 0, value));
        } else if (id.equals("ETT")) {
            value = ((FieldBodyETT) field.getBody()).getTitle();
            this.setBody(new FrameBodyTIT2((byte) 0, value));
        } else if (id.equals("IMG")) {
            throw new InvalidTagException("Cannot create ID3v2.40 frame from Lyrics3 image field.");
        } else {
            throw new InvalidTagException("Cannot caret ID3v2.40 frame from " + id + " Lyrics3 field");
        }
    }
View Full Code Here


        final String identifier = new String(buffer, 0, 4);

        // is this a valid identifier?
        if (isValidID3v2FrameIdentifier(identifier) == false) {
            file.seek(file.getFilePointer() - 3);
            throw new InvalidTagException(identifier + " is not a valid ID3v2.40 frame");
        }
        filePointer = file.getFilePointer();

        // skip the 4 byte size
        file.skipBytes(4);
View Full Code Here

            // we need to skip the flag bytes;
            file.skipBytes(2);
        }
        if (size == 0) {
            throw new InvalidTagException("Found empty frame");
        }
        if (size <= 0 || size > file.length()) {
            throw new InvalidTagException("Invalid size for Frame Body");
        }
        return size;
    }
View Full Code Here

            // int is 4 bytes.
            final int extendedHeaderSize = file.readInt();

            // the extended header is only 6 or 10 bytes.
            if (extendedHeaderSize != 6 && extendedHeaderSize != 10) {
                throw new InvalidTagException("Invalid Extended Header Size.");
            }
            file.read(buffer, 0, 2);
            this.crcDataFlag = (buffer[0] & TagConstant.MASK_V23_CRC_DATA_PRESENT) != 0;

            // if it's 10 bytes, the CRC flag must be set
            // and if it's 6 bytes, it must not be set
            if (((extendedHeaderSize == 10) && (this.crcDataFlag == false)) ||
                ((extendedHeaderSize == 6) && (this.crcDataFlag == true))) {
                throw new InvalidTagException("CRC Data flag not set correctly.");
            }
            this.paddingSize = file.readInt();
            if ((extendedHeaderSize == 10) && this.crcDataFlag) {
                this.crcData = file.readInt();
            }
View Full Code Here

        final String identifier = new String(buffer, 0, 4);

        // is this a valid identifier?
        if (isValidID3v2FrameIdentifier(identifier) == false) {
            file.seek(file.getFilePointer() - 3);
            throw new InvalidTagException(identifier + " is not a valid ID3v2.30 frame");
        }
        filePointer = file.getFilePointer();

        // skip the 4 byte size
        file.skipBytes(4);
View Full Code Here

        final String identifier = new String(buffer, 0, 3);

        // is this a valid identifier?
        if (isValidID3v2FrameIdentifier(identifier) == false) {
            file.seek(file.getFilePointer() - 2);
            throw new InvalidTagException(identifier + " is not a valid ID3v2.20 frame");
        }
        this.setBody(readBody(identifier, file));
    }
View Full Code Here

*/
public class MP3 {

    public static void main(String[] args) {
        try {
            MP3File mp3 = new MP3File(new File("C:/JPlayer/teste2.mp3"));
            TagOptionSingleton.getInstance().setDefaultSaveMode(TagConstant.MP3_FILE_SAVE_OVERWRITE);

//            // setup id3v1
//            ID3v1 id3v1 = mp3.getID3v1Tag();
//            Iterator t = id3v1.iterator();
//            id3v1.setTitle("Oi2");
//            mp3.setID3v1Tag(id3v1);


            mp3.getID3v2Tag().setAlbumTitle("owwwww");



//            // setup id3v2
//            AbstractID3v2Frame frame;
//            AbstractID3v2FrameBody frameBody;
//            frameBody = new FrameBodyTALB((byte) 0, "albumTitle");
//            frame = new ID3v2_4Frame(frameBody);

//            mp3.getID3v2Tag().setFrame(frame);
//
//            // setup lyrics3v2
//            AbstractLyrics3 lyrics3 = mp3.getLyrics3Tag();
//
//            Lyrics3v2Field field;
//            AbstractLyrics3v2FieldBody fieldBody;
//            fieldBody = new FieldBodyEAL("albumTitle");
//            field = new Lyrics3v2Field(fieldBody);
//            lyrics3.setField(field);
//
            // setup filename tag
//            frameBody = new FrameBodyTALB((byte) 0, "albumTitle");
//            frame = new ID3v2_4Frame(frameBody);
//            filenameId3.setFrame(frame);
            TagOptionSingleton.getInstance().setFilenameTagSave(true);

            mp3.save();
           


            System.out.println(mp3.toString());
        } catch (Exception ex) {
            Logger.getLogger(MP3.class.getName()).log(Level.SEVERE, null, ex);
        }


View Full Code Here

        montarGeneros();
        jTextField_Interp.setCrepzBuscador(this);
        jTextField_Album.setCrepzBuscador(this);

        try {
            mp3File = new MP3File(musica.getCaminho());
            setDadosv2();
        } catch (IOException ex) {
            throw new Exception("-Erro ao Carregar Propriedades do arquivo " + musica.getNome() + " \n", ex);
        } catch (TagException ex) {
            throw new Exception("-Erro ao Carregar Propriedades do arquivo " + mp3File.getMp3file().getName() + " \n", ex);
View Full Code Here

                String caminho = file.getAbsolutePath().trim().replace('\\', '/');
                if (listaNegra.contains(caminho)) {
                    System.out.println("Não importado, pois está na lista temporária de regeição: " + caminho);
                    return null;
                }
                MP3File mp3;
                try {
                    mp3 = new MP3File(caminho);
                    MusicaS musica = getMusica(mp3, file);
                    if (organizarPastas) {
                        File destinoF = new File(destino);
                        destinoF.mkdirs();
                        destinoF = new File(destinoF.getAbsolutePath() + "/" + file.getName());
                        if (!destinoF.getAbsolutePath().equals(file.getAbsolutePath())) {
                            if (file.renameTo(destinoF)) {
                                file = destinoF;
                            }
                            caminho = file.getAbsolutePath().replace('\\', '/');
                            mp3 = new MP3File(caminho);
                            musica = getMusica(mp3, file);
                        }

                    }
                    if (musica != null) {
View Full Code Here

    try {
      tmp = File.createTempFile("nutch", ".mp3");
      FileOutputStream fos = new FileOutputStream(tmp);
      fos.write(raw);
      fos.close();
      MP3File mp3 = new MP3File(tmp);

      if (mp3.hasID3v2Tag()) {
        parse = getID3v2Parse(mp3, content.getMetadata());
      } else if (mp3.hasID3v1Tag()) {
        parse = getID3v1Parse(mp3, content.getMetadata());
      } else {
        return new ParseStatus(ParseStatus.FAILED,
                               ParseStatus.FAILED_MISSING_CONTENT,
                               "No textual content available").getEmptyParse(conf);
View Full Code Here

TOP

Related Classes of org.farng.mp3.InvalidTagException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.