taglib

package
v0.0.0-...-38a11b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 10

Documentation

Overview

Package taglib provides utilities for parsing audio tags in various formats.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericTag

type GenericTag interface {
	Title() string
	Artist() string
	Album() string
	Comment() string
	Genre() string
	Year() time.Time
	Track() uint32
	Disc() uint32

	// CustomFrames returns non-standard, user-defined frames as a map from
	// descriptions (e.g. "PERFORMER", "MusicBrainz Album Id", etc.) to
	// values.
	CustomFrames() map[string]string

	// TagSize returns the total size of the tag's header and frames,
	// i.e. the position at which audio data starts.
	TagSize() uint32
}

GenericTag is implemented by all the tag types in this project. It gives an incomplete view of the information in each tag type, but is good enough for most purposes.

func Decode

func Decode(r io.ReaderAt, size int64) (GenericTag, error)

Decode reads r and determines which tag format the data is in, if any, and calls the decoding function for that format. size indicates the total number of bytes accessible through r.

Example
f, err := os.Open("testdata/BeatThee.mp3")
if err != nil {
	panic(err)
}
fi, err := f.Stat()
if err != nil {
	panic(err)
}
tag, err := Decode(f, fi.Size())
if err != nil {
	panic(err)
}

fmt.Println("Title:", strings.TrimSpace(tag.Title()))
fmt.Println("Artist:", strings.TrimSpace(tag.Artist()))
fmt.Println("Album:", strings.TrimSpace(tag.Album()))
fmt.Println("Track:", tag.Track())
Output:

Title: Beat Thee
Artist: Alexander Nakarada
Album: Complete Discography (CC BY Attribution 4.0)
Track: 189

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL