예제 #1
0
파일: Abs.php 프로젝트: lokamaya/zend-mp3
 /**
  * Reads frames up to given limit. If called subsequently the method
  * continues after the last frame read in the last call, again to read up
  * to the limit or just the rest of the frames.
  *
  * @param integer $limit The maximum number of frames read from the
  *                       bitstream
  */
 private function _readFrames($limit = null)
 {
     if ($limit === null || $limit > 200) {
         $limit = 200;
     }
     if ($this->_lastFrameOffset !== false) {
         $this->_reader->setOffset($this->_lastFrameOffset);
     }
     for ($i = 0; ($j = $this->_reader->getOffset()) < $this->_bytes; $i++) {
         $options = $this->getOptions();
         $frame = new Zend_Media_Mpeg_Abs_Frame($this->_reader, $options);
         $this->_cumulativePlayDuration += (double) ($frame->getLength() / ($frame->getBitrate() * 1000 / 8));
         $this->_cumulativeBitrate += $frame->getBitrate();
         $this->_frames[] = $frame;
         if ($limit === null) {
             $this->_lastFrameOffset = $this->_reader->getOffset();
         }
         if ($limit !== null && $i + 1 == $limit || $limit !== null && $j + $frame->getLength() >= $this->_bytes) {
             $this->_lastFrameOffset = $this->_reader->getOffset();
             break;
         }
     }
 }