@Test public void testRead() throws Exception { File testFile = TestUtil.copyAudioToTmp("test.m4a"); Mp4AudioFileReader reader = new Mp4AudioFileReader(); final AudioFile m4a = reader.read(testFile, "m4a", false); assertThat(m4a.getTag().isPresent(), is(true)); }
public AudioFile read(final File file, final String extension, final boolean ignoreArtwork) throws CannotReadException, FileNotFoundException { try (BufferedSource bufferedSource = Okio.buffer(Okio.source(file))) { Mp4FtypBox mp4FtypBox = new Mp4FtypBox(bufferedSource); LOG.log(DEBUG, "%s", mp4FtypBox); Mp4BoxHeader boxHeader = new Mp4BoxHeader(bufferedSource); while (!Mp4AtomIdentifier.MOOV.getFieldName().equals(boxHeader.getId())) { LOG.log(WARN, "Expected %s found %s", Mp4AtomIdentifier.MOOV, boxHeader); bufferedSource.skip(boxHeader.getDataLength()); boxHeader = new Mp4BoxHeader(bufferedSource); } Mp4MoovBox moovBox = new Mp4MoovBox(boxHeader, bufferedSource, mp4FtypBox, file.length(), ignoreArtwork); return new AudioFileImpl(file, extension, moovBox.getAudioHeader(), moovBox.getMp4Tag()); } catch (FileNotFoundException e) { throw e; } catch (IOException e) { throw new CannotReadException(e, ErrorMessage.MP4_FILE_NOT_CONTAINER); } }
Mp4AudioFileReader extends AudioFileReader { public AudioFile read(final File file, final String extension, final boolean ignoreArtwork) throws CannotReadException, FileNotFoundException { try (BufferedSource bufferedSource = Okio.buffer(Okio.source(file))) { Mp4FtypBox mp4FtypBox = new Mp4FtypBox(bufferedSource); LOG.log(DEBUG, "%s", mp4FtypBox); Mp4BoxHeader boxHeader = new Mp4BoxHeader(bufferedSource); while (!Mp4AtomIdentifier.MOOV.getFieldName().equals(boxHeader.getId())) { LOG.log(WARN, "Expected %s found %s", Mp4AtomIdentifier.MOOV, boxHeader); bufferedSource.skip(boxHeader.getDataLength()); boxHeader = new Mp4BoxHeader(bufferedSource); } Mp4MoovBox moovBox = new Mp4MoovBox(boxHeader, bufferedSource, mp4FtypBox, file.length(), ignoreArtwork); return new AudioFileImpl(file, extension, moovBox.getAudioHeader(), moovBox.getMp4Tag()); } catch (FileNotFoundException e) { throw e; } catch (IOException e) { throw new CannotReadException(e, ErrorMessage.MP4_FILE_NOT_CONTAINER); } } }
Mp4AudioFileReader extends AudioFileReader { public AudioFile read(final File file, final String extension, final boolean ignoreArtwork) throws CannotReadException, FileNotFoundException { try (BufferedSource bufferedSource = Okio.buffer(Okio.source(file))) { Mp4FtypBox mp4FtypBox = new Mp4FtypBox(bufferedSource); LOG.log(DEBUG, "%s", mp4FtypBox); Mp4BoxHeader boxHeader = new Mp4BoxHeader(bufferedSource); while (!Mp4AtomIdentifier.MOOV.getFieldName().equals(boxHeader.getId())) { LOG.log(WARN, "Expected %s found %s", Mp4AtomIdentifier.MOOV, boxHeader); bufferedSource.skip(boxHeader.getDataLength()); boxHeader = new Mp4BoxHeader(bufferedSource); } Mp4MoovBox moovBox = new Mp4MoovBox(boxHeader, bufferedSource, mp4FtypBox, file.length(), ignoreArtwork); return new AudioFileImpl(file, extension, moovBox.getAudioHeader(), moovBox.getMp4Tag()); } catch (FileNotFoundException e) { throw e; } catch (IOException e) { throw new CannotReadException(e, ErrorMessage.MP4_FILE_NOT_CONTAINER); } }  }
Mp4AudioFileReader extends AudioFileReader { public AudioFile read(final File file, final String extension, final boolean ignoreArtwork) throws CannotReadException, FileNotFoundException { try (BufferedSource bufferedSource = Okio.buffer(Okio.source(file))) { Mp4FtypBox mp4FtypBox = new Mp4FtypBox(bufferedSource); LOG.log(DEBUG, "%s", mp4FtypBox); Mp4BoxHeader boxHeader = new Mp4BoxHeader(bufferedSource); while (!Mp4AtomIdentifier.MOOV.getFieldName().equals(boxHeader.getId())) { LOG.log(WARN, "Expected %s found %s", Mp4AtomIdentifier.MOOV, boxHeader); bufferedSource.skip(boxHeader.getDataLength()); boxHeader = new Mp4BoxHeader(bufferedSource); } Mp4MoovBox moovBox = new Mp4MoovBox(boxHeader, bufferedSource, mp4FtypBox, file.length(), ignoreArtwork); return new AudioFileImpl(file, extension, moovBox.getAudioHeader(), moovBox.getMp4Tag()); } catch (FileNotFoundException e) { throw e; } catch (IOException e) { throw new CannotReadException(e, ErrorMessage.MP4_FILE_NOT_CONTAINER); } }  AudioFile read(final File file,
                        final String extension,
                        final boolean ignoreArtwork); }
Mp4AudioFileReader extends AudioFileReader { public AudioFile read(final File file, final String extension, final boolean ignoreArtwork) throws CannotReadException, FileNotFoundException { try (BufferedSource bufferedSource = Okio.buffer(Okio.source(file))) { Mp4FtypBox mp4FtypBox = new Mp4FtypBox(bufferedSource); LOG.log(DEBUG, "%s", mp4FtypBox); Mp4BoxHeader boxHeader = new Mp4BoxHeader(bufferedSource); while (!Mp4AtomIdentifier.MOOV.getFieldName().equals(boxHeader.getId())) { LOG.log(WARN, "Expected %s found %s", Mp4AtomIdentifier.MOOV, boxHeader); bufferedSource.skip(boxHeader.getDataLength()); boxHeader = new Mp4BoxHeader(bufferedSource); } Mp4MoovBox moovBox = new Mp4MoovBox(boxHeader, bufferedSource, mp4FtypBox, file.length(), ignoreArtwork); return new AudioFileImpl(file, extension, moovBox.getAudioHeader(), moovBox.getMp4Tag()); } catch (FileNotFoundException e) { throw e; } catch (IOException e) { throw new CannotReadException(e, ErrorMessage.MP4_FILE_NOT_CONTAINER); } }  AudioFile read(final File file,
                        final String extension,
                        final boolean ignoreArtwork);  }