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

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

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

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

Definition at line 253 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.

Referenced by getPlayingTimeString().

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

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index