diff --git a/frame.go b/frame.go index be7c0d7..18576ef 100644 --- a/frame.go +++ b/frame.go @@ -84,6 +84,15 @@ func (f DataFrame) Bytes() []byte { return f.data } +// TextFramer represents frames that contain encoded text +type TextFramer interface { + Framer + Encoding() string + SetEncoding(string) error + Text() string + SetText(string) error +} + // TextFrame represents frames that contain encoded text type TextFrame struct { FrameHead diff --git a/id3v2.go b/id3v2.go index 9fa7219..dbdbce3 100644 --- a/id3v2.go +++ b/id3v2.go @@ -197,12 +197,10 @@ func (t *Tag) SetGenre(text string) { t.setTextFrameText(t.commonMap["Genre"], text) } -func (t *Tag) textFrame(id string) *TextFrame { +func (t *Tag) textFrame(id string) TextFramer { if frame := t.Frame(id); frame != nil { - switch frame.(type) { - case (*TextFrame): - return frame.(*TextFrame) - default: + if textFramer, ok := frame.(TextFramer); ok { + return textFramer } }