/
EXAMPLES
40 lines (28 loc) · 885 Bytes
/
EXAMPLES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
= Examples
require "mp3info"
# read and display infos & tags
Mp3Info.open("myfile.mp3") do |mp3info|
puts mp3info
end
# read/write tag1 and tag2 with Mp3Info#tag attribute
# when reading tag2 have priority over tag1
# when writing, each tag is written.
Mp3Info.open("myfile.mp3") do |mp3|
puts mp3.tag.title
puts mp3.tag.artist
puts mp3.tag.album
puts mp3.tag.tracknum
mp3.tag.title = "track title"
mp3.tag.artist = "artist name"
end
Mp3Info.open("myfile.mp3") do |mp3|
# you can access four letter v2 tags like this
puts mp3.tag2.TIT2
mp3.tag2.TIT2 = "new TIT2"
# or like that
mp3.tag2["TIT2"]
# at this time, only COMM tag is processed after reading and before writing
# according to ID3v2#options hash
mp3.tag2.options[:lang] = "FRE"
mp3.tag2.COMM = "my comment in french, correctly handled when reading and writing"
end