code: func (d *Decoder) Duration() (time.Duration, error) {
  	if d == nil {
  		return 0, errors.New("can't calculate the duration of a nil pointer")
  	}
  	fr := &Frame{}
  	var frameDuration time.Duration
  	var duration time.Duration
  	var err error
  	for {
  		err = d.Next(fr)
  		if err != nil {
  			// bad headers can be ignored and hopefully skipped
  			if err == ErrInvalidHeader {
  				continue
  			}
  			break
  		}
  		frameDuration = fr.Duration()
  		if frameDuration > 0 {
  			duration += frameDuration
  		}
  		d.NbrFrames++
  	}
  	if err == io.EOF || err == io.ErrUnexpectedEOF || err == io.ErrShortBuffer {
  		err = nil
  	}
  
  	return duration, err
  }
docs: // Duration returns the time duration for the current mp3 file
  // The entire reader will be consumed, the consumer might want to rewind the reader
  // if they want to read more from the feed.
  // Note that this is an estimated duration based on how the frames look. An invalid file might have
  // a duration.