Package org.farng.mp3

Examples of org.farng.mp3.MP3File


    EasyMock.verify(id3Mock, mp3FileMock);
  }
 
  private void testID3v2Genre(String input, String expectedOutput) throws ID3TagFileException {
    AbstractID3v2 id3Mock = EasyMock.createMock(AbstractID3v2.class);
    MP3File mp3FileMock = TagTestHelpLibrary.createMP3FileMockForID3v2(id3Mock);

    EasyMock.expect(id3Mock.getSongGenre()).andReturn(input);
    EasyMock.replay(id3Mock, mp3FileMock);

    ID3Tag tag = jidID3TagFactory.getID3Tag(mp3FileMock);
View Full Code Here


    jidID3TagFactory.getID3Tag(fileMock);
  }
 
  @Test
  public void ID3v1Test() throws ID3TagFileException{
    MP3File mp3FileMock = TagTestHelpLibrary.createMP3FileMockForID3v1(null);
    EasyMock.replay(mp3FileMock);
   
    ID3Tag id3Tag = jidID3TagFactory.getID3Tag(mp3FileMock);
 
    assertTrue(id3Tag.getClass().equals(ID3v1TagImpl.class));
View Full Code Here

    EasyMock.verify(mp3FileMock);
  }
 
  @Test
  public void ID3v2Test() throws ID3TagFileException{
    MP3File mp3FileMock = TagTestHelpLibrary.createMP3FileMockForID3v2(null);
    EasyMock.replay(mp3FileMock);
   
    ID3Tag id3Tag = jidID3TagFactory.getID3Tag(mp3FileMock);
 
    assertTrue(id3Tag.getClass().equals(ID3v2TagImpl.class));
View Full Code Here

    if (isM4A(file)) {
      throw new ID3M4AException(file);
    }

    try {
      MP3File mp3File = new MP3File(file, NOT_WRITEABLE);
      return getID3Tag(mp3File);

    } catch (IOException e) {
      throw new ID3TagFileException(e, file);
    } catch (TagException e) {
View Full Code Here

   *       </ul>
   */
  public static String[] getIDTags(String file) {
    String[] ret = new String[3];
    try {
      MP3File mp3 = new MP3File(file);
      String mtitle = null, martist=null, malbum=null;
      if(mp3.hasID3v1Tag()) {
        mtitle = mp3.getID3v1Tag().getTitle();
        martist = mp3.getID3v1Tag().getArtist();
        malbum = mp3.getID3v1Tag().getAlbum();
      } else if(mp3.hasID3v2Tag()) {
        mtitle = mp3.getID3v2Tag().getSongTitle();
        martist = mp3.getID3v2Tag().getLeadArtist();
        malbum = mp3.getID3v2Tag().getAlbumTitle();
      }
      ret[0] = toUTF8(martist);
      ret[1] = toUTF8(malbum);
      ret[2] = toUTF8(mtitle);
    } catch (Exception e) {
View Full Code Here

            // we have a parenthesis
            if (openIndex >= 0 && openIndex < token.length()) {
                close = option.getCloseParenthesis(open);
                closeIndex = TagUtility.findMatchingParenthesis(token, openIndex);
                if (closeIndex < 0) {
                    throw new TagException("Unmatched parenthesis in \"" + token + "\" at position : " + openIndex);
                }
                tokenArray = new String[5];
                tokenArray[0] = open;
                tokenArray[1] = close;
                tokenArray[2] = token.substring(0, openIndex);
View Full Code Here

            file.close();

            // copy, then delete
            TagUtility.copyFile(originalFile, newFile);
            if (!originalFile.delete()) {
                throw new TagException("Unable to delete original file: " + originalFile.getName());
            }
        }
    }
View Full Code Here

            textFrame = (AbstractFrameBodyTextInformation) frame.getBody();
            if ((textFrame != null) && ((textFrame.getText()).length() > 0)) {
                this.setBody(new FieldBodyETT((textFrame.getText())));
            }
        } else {
            throw new TagException("Cannot create Lyrics3v2 field from given ID3v2 frame");
        }
    }
View Full Code Here

    public void read(final RandomAccessFile file) throws TagException, IOException {
        final int size;
        byte[] buffer = new byte[4];
        file.seek(0);
        if (seek(file) == false) {
            throw new TagNotFoundException(getIdentifier() + " tag not found");
        }

        // read the major and minor @version bytes & flag bytes
        file.read(buffer, 0, 3);
        if ((buffer[0] != 4) || (buffer[1] != 0)) {
            throw new TagNotFoundException(getIdentifier() + " tag not found");
        }
        setMajorVersion(buffer[0]);
        setRevision(buffer[1]);
        this.unsynchronization = (buffer[2] & TagConstant.MASK_V24_UNSYNCHRONIZATION) != 0;
        this.extended = (buffer[2] & TagConstant.MASK_V24_EXTENDED_HEADER) != 0;
View Full Code Here

    public void read(final RandomAccessFile file) throws TagNotFoundException, IOException {
        final byte[] buffer = new byte[5100 + 9 + 11];
        final String lyricBuffer;
        if (seek(file) == false) {
            throw new TagNotFoundException("ID3v1 tag not found");
        }
        file.read(buffer);
        lyricBuffer = new String(buffer);
        this.lyric = lyricBuffer.substring(0, lyricBuffer.indexOf("LYRICSEND"));
    }
View Full Code Here

TOP

Related Classes of org.farng.mp3.MP3File

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.