Closed dimuls closed 6 years ago
I tried to implement it in this way but it is not working (track field leaves empty):
const trackFrameID = "TRCK"
// Track number id3v2.4 frame
type trackFrame struct {
TrackNumber int
TotalTracks int
}
func (tf trackFrame) encode() []byte {
return []byte(fmt.Sprintf("%d/%d", tf.TrackNumber, tf.TotalTracks))
}
func (tf trackFrame) Size() int {
return len(tf.encode())
}
func (tf trackFrame) WriteTo(w io.Writer) (int64, error) {
n, err := w.Write(tf.encode())
return int64(n), err
}
This works as needed:
mp3.AddFrame(trackFrameID, id3v2.TextFrame{Encoding: id3v2.EncodingUTF8,
Text: fmt.Sprintf("%d/%d", t.Number, len(a.Tracks))})
Issue can be closed, but consider to add SetTrack
. Thank you!
I will not add SetTrack
method, because it's pretty rarely used. I will keep methods only for artist, album, title and year.
But I added a convenience method for adding text frames in 7e43476:
tag.AddTextFrame(tag.CommonID("Track number/Position in set"), tag.DefaultEncoding(), fmt.Sprintf("%d/%d", t.Number, len(a.Tracks))}))
You have nice library, but i miss
SetTrack
method to set track number. Can you implement it please?