Block
#struct BlockOne FLAC metadata block, as the tag reader walks them.
| Name | Type | Description |
|---|---|---|
kind | int = 0 | Which Block number it is. |
offset | int = 0 | Where the body starts. |
size | int = 0 | How many bytes it holds. |
last | bool = false | True on the final block. |
import audio.tag
import compress
import str
func main:
mut t := tag.NewTags()
t.title = str.Clone("Zagros")
t.artist = str.Clone("Darya")
t.year = 2026
t.track = 2
mut vc := tag.WriteVorbisComment(t)
println compress.BufLen(vc) > 8
mut g := tag.NewTags()
println tag.ReadVorbisComment(vc.data, 0, vc.len, g)
println g.title, g.artist, g.year, g.track
mut fl := compress.NewByteBuf()
compress.BufPush(fl, 102)
compress.BufPush(fl, 76)
compress.BufPush(fl, 97)
compress.BufPush(fl, 67)
compress.BufPush(fl, 128 | tag.BlockVorbisComment)
n := compress.BufLen(vc)
compress.BufPush(fl, (n >> 16) & 255)
compress.BufPush(fl, (n >> 8) & 255)
compress.BufPush(fl, n & 255)
compress.BufPushBuf(fl, vc)
println tag.IsFlacTagged(fl.data, fl.len)
blocks := tag.FlacBlocks(fl.data, fl.len)
println blocks.Len(), blocks.Get(0).kind == tag.BlockVorbisComment, blocks.Get(0).last
println blocks.Get(0).size == n
mut gf := tag.NewTags()
println tag.ReadFlacTags(fl.data, fl.len, gf)
println gf.title, gf.artist
mut aok := false
mut auto := tag.ReadTags(fl.data, fl.len, aok)
println aok, auto.title
println tag.EncUtf8, tag.EncLatin1, tag.EncUtf16, tag.EncUtf16BE
blocks.Free()
tag.FreeTags(t)
tag.FreeTags(g)
tag.FreeTags(gf)
tag.FreeTags(auto)
compress.BufFree(vc)
compress.BufFree(fl)
endtrue true Zagros Darya 2026 2 true 1 true true true true Zagros Darya true Zagros 3 0 1 2