Add simple example and improve ReadFrom godoc.

This commit is contained in:
David Howden 2015-06-28 10:32:57 +10:00
parent cc7e8af340
commit a579928cb2

20
tag.go
View File

@ -2,8 +2,16 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package tag provides MP3 (ID3: v1, 2.2, 2.3 and 2.4), MP4, FLAC and OGG metadata parsing and
// artwork extraction.
// Package tag provides MP3 (ID3: v1, 2.2, 2.3 and 2.4), MP4, FLAC and OGG metadata detection,
// parsing and artwork extraction.
// Detect and parse tag metadata from an io.ReadSeeker (i.e. an *os.File):
// m, err := tag.ReadFrom(f)
// if err != nil {
// log.Fatal(err)
// }
// log.Print(m.Format()) // The detected format.
// log.Print(m.Title()) // The title of the track (see Metadata interface for more details).
package tag
import (
@ -17,11 +25,9 @@ import (
// cannot be identified.
var ErrNoTagsFound = errors.New("no tags found")
// ReadFrom parses audio file metadata tags (currently supports ID3v1,2.{2,3,4} and MP4).
// This method attempts to determine the format of the data provided by the io.ReadSeeker,
// and then chooses ReadAtoms (MP4), ReadID3v2Tags (ID3v2.{2,3,4}) or ReadID3v1Tags as
// appropriate. Returns non-nil error if the format of the given data could not be determined,
// or if there was a problem parsing the data.
// ReadFrom detects and parses audio file metadata tags (currently supports ID3v1,2.{2,3,4}, MP4, FLAC/OGG).
// Returns non-nil error if the format of the given data could not be determined, or if there was a problem
// parsing the data.
func ReadFrom(r io.ReadSeeker) (Metadata, error) {
b, err := readBytes(r, 11)
if err != nil {