feat(ncm): support audio meta getter

This commit is contained in:
Unlock Music Dev
2022-11-22 07:08:10 +08:00
parent c878bb8ca4
commit 138adbf846
5 changed files with 50 additions and 23 deletions

View File

@@ -29,6 +29,7 @@ func RegisterDecoder(ext string, noop bool, dispatchFunc NewDecoderFunc) {
DecoderRegistry[ext] = append(DecoderRegistry[ext],
decoderItem{noop: noop, decoder: dispatchFunc})
}
func GetDecoder(filename string, skipNoop bool) (rs []NewDecoderFunc) {
ext := strings.ToLower(strings.TrimLeft(filepath.Ext(filename), "."))
for _, dec := range DecoderRegistry[ext] {

View File

@@ -5,6 +5,10 @@ import (
"io"
)
type StreamDecoder interface {
Decrypt(buf []byte, offset int)
}
type Decoder interface {
Validate() error
io.Reader
@@ -14,12 +18,12 @@ type CoverImageGetter interface {
GetCoverImage(ctx context.Context) ([]byte, error)
}
type Meta interface {
type AudioMeta interface {
GetArtists() []string
GetTitle() string
GetAlbum() string
}
type StreamDecoder interface {
Decrypt(buf []byte, offset int)
type AudioMetaGetter interface {
GetAudioMeta(ctx context.Context) (AudioMeta, error)
}