Пример #1
0
func (v *Vorbis) Info() (info codec.SongInfo, err error) {
	if v.info != nil {
		return *v.info, nil
	}
	si, _, b, err := v.Reader.Metadata(tag.OGG)
	if err != nil {
		return
	}
	or := ogg.NewReader(bytes.NewReader(b))
	vr, err := vorbis.OpenOgg(or)
	if err != nil {
		return
	}
	l, err := or.Length()
	if err != nil {
		return
	}
	si.Time = time.Duration(l/uint64(vr.SampleRate())) * time.Second
	v.info = si
	return *si, nil
}
Пример #2
0
// Open reads the vorbis headers from an io.Reader and performs the setup needed to decode the data.
func Open(in io.Reader) (*Vorbis, error) {
	return OpenOgg(ogg.NewReader(in))
}