Logo Search packages:      
Sourcecode: jampal version File versions  Download package

long pgbennett::id3::MP3File::getPlayingTimeMs (  ) [inline]

Returns the length (in milliseconds) of the playing time of this mp3. This will not return an accurate value for VBR files.

Returns:
the playing time (in mseconds) of this mp3

Definition at line 282 of file MP3File.java.

References pgbennett::id3::ID3v1Tag::getSize(), pgbennett::id3::ID3v2Tag::getSize(), pgbennett::id3::MPEGAudioFrameHeader::getVBRPlayingTime(), head, id3v1, id3v2, pgbennett::id3::MPEGAudioFrameHeader::isVBR(), and mp3.

                                   {
        long time = 0;
        
        if (head.isVBR()) {
            time = head.getVBRPlayingTime() * 1000;
        } else {
            long datasize = mp3.length() - id3v2.getSize()
            - id3v1.getSize();
            long kbps = getBitRate();
            
            // Avoid divide by zero error
            if (kbps == 0) {
                time = 0;
            } else {
                time = datasize * 8 / kbps;
            }
        }
        
        return time;
    }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index