Package entagged.audioformats.mp4

Examples of entagged.audioformats.mp4.Mp4Tag


     *      xxxx <-  id de l'info
     *       data
     *      ]
     */
    public Mp4Tag read( RandomAccessFile raf ) throws CannotReadException, IOException {
        Mp4Tag tag = new Mp4Tag();
       
        Mp4Box box = new Mp4Box();
        byte[] b = new byte[4];
       
        //Get to the facts
        //1-Searching for "moov"
        seek(raf, box, "moov");
       
        //2-Searching for "udta"
        seek(raf, box, "udta");
       
        //3-Searching for "meta"
        seek(raf, box, "meta");
       
        //4-skip the meta flags
        raf.read(b);
        if(b[0] != 0)
            throw new CannotReadException();
       
        //5-Seek the "ilst"
        seek(raf, box, "ilst");
        int length = box.getOffset() - 8;
       
        int read = 0;
        while(read < length) {
            b = new byte[8];
            raf.read(b);
            box.update(b);
                          
            int fieldLength = box.getOffset() - 8;
            b = new byte[fieldLength];
            raf.read(b);
           
            tag.add(createMp4Field(box.getId(), b));
            read += 8+fieldLength;
        }
       
        System.out.println(tag);
        return tag;
View Full Code Here


    protected String getGenreId() {
        return "gen";
    }
   
    protected TagField createArtistField(String content) {
        return new Mp4TagTextField("ART", content);
    }
View Full Code Here

   
    protected TagField createArtistField(String content) {
        return new Mp4TagTextField("ART", content);
    }
    protected TagField createAlbumField(String content) {
        return new Mp4TagTextField("alb", content);
    }
View Full Code Here

    }
    protected TagField createAlbumField(String content) {
        return new Mp4TagTextField("alb", content);
    }
    protected TagField createTitleField(String content) {
        return new Mp4TagTextField("nam", content);
    }
View Full Code Here

    }
    protected TagField createTrackField(String content) {
        return new Mp4TagTextNumberField("trkn", content);
    }
    protected TagField createYearField(String content) {
        return new Mp4TagTextField("day", content);
    }
View Full Code Here

    }
    protected TagField createYearField(String content) {
        return new Mp4TagTextField("day", content);
    }
    protected TagField createCommentField(String content) {
        return new Mp4TagTextField("cmt", content);
    }
View Full Code Here

    }
    protected TagField createCommentField(String content) {
        return new Mp4TagTextField("cmt", content);
    }
    protected TagField createGenreField(String content) {
        return new Mp4TagTextField("gen", content);
    }
View Full Code Here

    }
    protected TagField createTitleField(String content) {
        return new Mp4TagTextField("nam", content);
    }
    protected TagField createTrackField(String content) {
        return new Mp4TagTextNumberField("trkn", content);
    }
View Full Code Here

    public void parse( File file ) throws IOException {

        try {
            AudioFile f = AudioFileIO.read(file);
            Mp4Tag mp4tag = (Mp4Tag) f.getTag();

            this.artistTitle = mp4tag.getFirst(Mp4FieldKey.ARTIST);
            this.albumTitle = mp4tag.getFirst(Mp4FieldKey.ALBUM);
            this.albumArtist = mp4tag.getFirst(Mp4FieldKey.ALBUM_ARTIST);
            this.trackTitle = mp4tag.getFirst(FieldKey.TITLE);
            this.genre = mp4tag.getFirst(FieldKey.GENRE);
            this.trackNumber = ((Mp4TrackField) mp4tag.getFirstField(Mp4FieldKey.TRACK)).getTrackNo();
           
        } catch ( Exception e) {
            throw new IOException("Unable to read file: " + file.getName(), e);
        }
    }
View Full Code Here

        return (ext.equalsIgnoreCase("mp4") || ext.equalsIgnoreCase("m4a"));
    }

    @Override
    protected void copySpecificTagFields(Tag tag, Track track) {
        Mp4Tag mp4Tag = (Mp4Tag) tag;
        TrackData trackData = track.getTrackData();

        Mp4TrackField trackField = (Mp4TrackField) mp4Tag.getFirstField(Mp4FieldKey.TRACK);
        if (trackField != null) {
            if (trackField.getTrackNo() != null) {
                trackData.addTrack(trackField.getTrackNo().intValue());
            }
            if (trackField.getTrackTotal() != null) {
                trackData.addTrackTotal(trackField.getTrackTotal().intValue());
            }
        }

        Mp4DiscNoField discField = (Mp4DiscNoField) mp4Tag.getFirstField(Mp4FieldKey.DISCNUMBER);
        if (discField != null) {
            if (discField.getDiscNo() != null) {
                trackData.addDisc(discField.getDiscNo().intValue());
            }
            if (discField.getDiscTotal() != null) {
                trackData.addDiscTotal(discField.getDiscTotal().intValue());
            }
        }

        List<TagField> genreFields = new ArrayList<TagField>();
        genreFields.addAll(mp4Tag.get(Mp4FieldKey.GENRE_CUSTOM));
        genreFields.addAll(mp4Tag.get(Mp4FieldKey.GENRE_ITUNES));
        for (TagField genreField : genreFields) {
            trackData.addGenre(genreField.toString());
        }
    }
View Full Code Here

TOP

Related Classes of entagged.audioformats.mp4.Mp4Tag

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.