Search in sources :

Example 1 with IsoFile

use of com.frostwire.mp4.IsoFile in project frostwire by frostwire.

the class MediaPlayer method getDurationFromM4A.

private long getDurationFromM4A(File f) {
    try {
        RandomAccessFile isoFile = new RandomAccessFile(f, "r");
        LinkedList<com.frostwire.mp4.Box> boxes = IsoFile.head(isoFile, ByteBuffer.allocate(100 * 1024));
        try {
            MovieHeaderBox mvhd = com.frostwire.mp4.Box.findFirst(boxes, com.frostwire.mp4.Box.mvhd);
            if (mvhd != null) {
                return mvhd.duration() / mvhd.timescale();
            }
        } finally {
            IOUtils.closeQuietly(isoFile);
        }
    } catch (Throwable e) {
        return -1;
    }
    return -1;
}
Also used : RandomAccessFile(java.io.RandomAccessFile) MovieHeaderBox(com.frostwire.mp4.MovieHeaderBox) MovieHeaderBox(com.frostwire.mp4.MovieHeaderBox)

Aggregations

MovieHeaderBox (com.frostwire.mp4.MovieHeaderBox)1 RandomAccessFile (java.io.RandomAccessFile)1