Register Decoder With Default Output Ext
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
package common
|
||||
|
||||
type RawDecoder struct {
|
||||
file []byte
|
||||
file []byte
|
||||
audioExt string
|
||||
}
|
||||
|
||||
//goland:noinspection GoUnusedExportedFunction
|
||||
func NewRawDecoder(file []byte) Decoder {
|
||||
return &RawDecoder{file: file}
|
||||
}
|
||||
@ -25,17 +27,21 @@ func (d RawDecoder) GetAudioData() []byte {
|
||||
}
|
||||
|
||||
func (d RawDecoder) GetAudioExt() string {
|
||||
return ""
|
||||
return d.audioExt
|
||||
}
|
||||
|
||||
func (d RawDecoder) GetMeta() Meta {
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterDecoder("mp3", NewRawDecoder)
|
||||
RegisterDecoder("flac", NewRawDecoder)
|
||||
RegisterDecoder("wav", NewRawDecoder)
|
||||
RegisterDecoder("ogg", NewRawDecoder)
|
||||
RegisterDecoder("m4a", NewRawDecoder)
|
||||
func DecoderFuncWithExt(ext string) NewDecoderFunc {
|
||||
return func(file []byte) Decoder {
|
||||
return &RawDecoder{file: file, audioExt: ext}
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
RegisterDecoder("mp3", DecoderFuncWithExt("mp3"))
|
||||
RegisterDecoder("flac", DecoderFuncWithExt("flac"))
|
||||
RegisterDecoder("wav", DecoderFuncWithExt("wav"))
|
||||
RegisterDecoder("ogg", DecoderFuncWithExt("ogg"))
|
||||
RegisterDecoder("m4a", DecoderFuncWithExt("m4a"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user