diff --git a/README.md b/README.md index 423a86c..9af6476 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Version specific details can be accessed through the subpackages. "github.com/mikkyang/id3-go/v2" ) -# Opening a File +# Quick Start To access the tag of a file, first open the file using the package's `Open` function. @@ -45,7 +45,7 @@ It's also a good idea to ensure that the file is closed using `defer`. defer mp3File.Close() -# Accessing Information +## Accessing Information Some commonly used data have methods in the tag for easier access. These methods are for `Title`, `Artist`, `Album`, `Year`, `Genre`, and `Comments`. @@ -53,7 +53,7 @@ methods are for `Title`, `Artist`, `Album`, `Year`, `Genre`, and `Comments`. mp3File.SetArtist("Okasian") fmt.Println(mp3File.Artist()) -## ID3v2 Frames +# ID3v2 Frames v2 Frames can be accessed directly by using the `Frame` or `Frames` method of the file, which return the first frame or a slice of frames as `Framer` @@ -68,3 +68,16 @@ The example provided does not check for errors, but it is recommended to do so. lyricsFrame := mp3File.Frame("USLT").(*v2.UnsynchTextFrame) + +## Adding Frames + +For common fields, a frame will automatically be created with the `Set` method. +For other frames or more fine-grained control, frames can be created with the +corresponding constructor, usually prefixed by `New`. These constructors require +the first argument to be a FrameType struct, which are global variables named by +version. + + ft := V23FrameTypeMap["TIT2"] + text := "Hello" + textFrame := NewTextFrame(ft, text) + mp3File.AddFrames(textFrame)