Salut,
J'aimerais connaitre comment lire le n° de piste enregistré dans un fichier mp3.
Merci
Leo
Salut,
J'aimerais connaitre comment lire le n° de piste enregistré dans un fichier mp3.
Merci
Leo
Dans un module mais ca fonctionne que pour ID3v1
Lire tag
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242 Option Explicit Type mp3Tag tagID As String * 3 title As String * 30 artist As String * 30 album As String * 30 year As String * 4 comment As String * 30 genre As String * 1 End Type Type genreListEntry genre As String End Type Public genreList(126) As genreListEntry Sub populateGenreList() genreList(0).genre = "Blues" genreList(1).genre = "Classic Rock" genreList(10).genre = "New Age" genreList(100).genre = "Humour" genreList(101).genre = "Speech" genreList(102).genre = "Chanson" genreList(103).genre = "Opera" genreList(104).genre = "Chamber Music" genreList(105).genre = "Sonata" genreList(106).genre = "Symphony" genreList(107).genre = "Booty Brass" genreList(108).genre = "Primus" genreList(109).genre = "Porn Groove" genreList(11).genre = "Oldies" genreList(110).genre = "Satire" genreList(111).genre = "Slow Jam" genreList(112).genre = "Club" genreList(113).genre = "Tango" genreList(114).genre = "Samba" genreList(115).genre = "Folklore" genreList(116).genre = "Ballad" genreList(117).genre = "Poweer Ballad" genreList(118).genre = "Rhytmic Soul" genreList(119).genre = "Freestyle" genreList(12).genre = "Other" genreList(120).genre = "Duet" genreList(121).genre = "Punk Rock" genreList(122).genre = "Drum Solo" genreList(123).genre = "A Capela" genreList(124).genre = "Euro-House" genreList(125).genre = "Dance Hall" genreList(13).genre = "Pop" genreList(14).genre = "R&B" genreList(15).genre = "Rap" genreList(16).genre = "Reggae" genreList(17).genre = "Rock" genreList(18).genre = "Techno" genreList(19).genre = "Industrial" genreList(2).genre = "Country" genreList(20).genre = "Alternative" genreList(21).genre = "Ska" genreList(22).genre = "Death Metal" genreList(23).genre = "Pranks" genreList(24).genre = "Soundtrack" genreList(25).genre = "Euro-Techno" genreList(26).genre = "Ambient" genreList(27).genre = "Trip-Hop" genreList(28).genre = "Vocal" genreList(29).genre = "Jazz+Funk" genreList(3).genre = "Dance" genreList(30).genre = "Fusion" genreList(31).genre = "Trance" genreList(32).genre = "Classical" genreList(33).genre = "Instrumental" genreList(34).genre = "Acid" genreList(35).genre = "House" genreList(36).genre = "Game" genreList(37).genre = "Sound Clip" genreList(38).genre = "Gospel" genreList(39).genre = "Noise" genreList(4).genre = "Disco" genreList(40).genre = "AlternRock" genreList(41).genre = "Bass" genreList(42).genre = "Soul" genreList(43).genre = "Punk" genreList(44).genre = "Space" genreList(45).genre = "Meditative" genreList(46).genre = "Instrumental Pop" genreList(47).genre = "InstrumentalRock" genreList(48).genre = "Ethnic" genreList(49).genre = "Gothic" genreList(5).genre = "Funk" genreList(50).genre = "Darkwave" genreList(51).genre = "Techno-Industrial" genreList(52).genre = "Electronic" genreList(53).genre = "Pop-Folk" genreList(54).genre = "Eurodance" genreList(55).genre = "Dream" genreList(56).genre = "Southern Rock" genreList(57).genre = "Comedy" genreList(58).genre = "Cult" genreList(59).genre = "Gangsta" genreList(6).genre = "Grunge" genreList(60).genre = "Top 40" genreList(61).genre = "Christian Rap" genreList(62).genre = "Pop/Funk" genreList(63).genre = "Jungle" genreList(64).genre = "Native American" genreList(65).genre = "Cabaret" genreList(66).genre = "New Wave" genreList(67).genre = "Psychadelic" genreList(68).genre = "Rave" genreList(69).genre = "Showtunes" genreList(7).genre = "Hip-Hop" genreList(70).genre = "Trailer" genreList(71).genre = "Lo-Fi" genreList(72).genre = "Tribal" genreList(73).genre = "Acid Punk" genreList(74).genre = "Acid Jazz" genreList(75).genre = "Polka" genreList(76).genre = "Retro" genreList(77).genre = "Musical" genreList(78).genre = "Rock&Roll" genreList(79).genre = "Hard Rock" genreList(8).genre = "Jazz" genreList(80).genre = "Folk" genreList(81).genre = "Folk-Rock" genreList(82).genre = "National Folk" genreList(83).genre = "Swing" genreList(84).genre = "Fast Fusion" genreList(85).genre = "Bebob" genreList(86).genre = "Latin" genreList(87).genre = "Revival" genreList(88).genre = "Celtic" genreList(89).genre = "Bluegrass" genreList(9).genre = "Metal" genreList(90).genre = "Avantgarde" genreList(91).genre = "Gothic Rock" genreList(92).genre = "Progressive Rock" genreList(93).genre = "Psychedelic Rock" genreList(94).genre = "Symphonic Rock" genreList(95).genre = "Slow Rock" genreList(96).genre = "Big Band" genreList(97).genre = "Chorus" genreList(98).genre = "Easy Listening" genreList(99).genre = "Acoustic" End Sub Function genreSearch(genreTag As String) As String Dim intGenreNumber As Integer If genreTag <> "" Then intGenreNumber = Asc(genreTag) Else intGenreNumber = 255 End If If intGenreNumber > 125 Then genreSearch = "Unknown Genre Entry" Else genreSearch = genreList(intGenreNumber).genre End If End Function Function getMp3Tag(strMP3FileName As String, tag As mp3Tag) As Boolean Dim endOfFile As Long Dim iFileHandle As Integer iFileHandle = FreeFile ' Find out what the next free file number is Open strMP3FileName For Binary As #iFileHandle ' open MP3 endOfFile = LOF(1) \ 1 'find out length of the file Get #iFileHandle, (endOfFile - 127), tag ' read in the last 128 characters of the mp3 Close #iFileHandle ' close the MP3 If tag.tagID = "TAG" Then 'If the tagid field contains the word "TAG" then it is a getMp3Tag = True 'valid MP3 Tag Else getMp3Tag = False End If End Function Function putMp3Tag(strMP3FileName As String, tag As mp3Tag) As Boolean Dim endOfFile As Long Dim iFileHandle As Integer Dim newTag As Boolean iFileHandle = FreeFile 'find out the next free file number If tag.tagID <> "TAG" Then tag.tagID = "TAG" 'the first three bytes of the tag must be "TAG" for it to be considered valid newTag = True 'we are adding a new tag to the MP3 Else newTag = False End If Open strMP3FileName For Binary As #iFileHandle ' open MP3 endOfFile = LOF(1) \ 1 'find out length of the file If newTag Then Put #iFileHandle, (endOfFile + 1), tag 'add tag to end of mp3 Else Put #iFileHandle, (endOfFile - 127), tag ' write tag in the last 128 characters of the mp3 End If Close #iFileHandle ' close the MP3 putMp3Tag = True End Function Function getGenreTagCode(strGenre As String) As String Dim i As Integer Dim genreMatchFound As Boolean genreMatchFound = False For i = 0 To 125 ' walk the list until a match is found and return the proper numberic value for the If strGenre = genreList(i).genre Then 'genre getGenreTagCode = Chr$(i) genreMatchFound = True Exit For ' match found, let's not waste time looking thru the rest of the list End If Next i If Not genreMatchFound Then getGenreTagCode = Chr$(12) End If End Function
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Dim endOfFile As Long Dim tag As mp3Tag CommonDialog1.ShowOpen ' Display File Open Dialog If CommonDialog1.FileName <> "" Then lblInputFile = CommonDialog1.FileName End If If getMp3Tag(lblInputFile, tag) Then txtTitle.tag = "TAG" txtTitle.Text = tag.title txtArtist.Text = tag.artist txtAlbum.Text = tag.album txtYear.Text = tag.year txtComment.Text = tag.comment cmbGenre.Text = genreSearch(tag.genre) Else txtTitle.tag = "" txtTitle.Text = "No ID Version 1.1 Tag Found" ' let the user know that there txtArtist.Text = "" ' is no tag txtAlbum.Text = "" txtYear.Text = "" txtComment.Text = "" cmbGenre.Text = "" End If
Enregistrer tag
Et alors sur le Form Load
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Dim tag As mp3Tag tag.title = txtTitle.Text tag.album = txtAlbum.Text tag.artist = txtArtist.Text tag.comment = txtComment.Text tag.genre = getGenreTagCode(cmbGenre.Text) tag.year = txtYear.Text tag.tagID = txtTitle.tag putMp3Tag lblInputFile, tag
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Private Sub Form_Load() populateGenreList
N'oubliez pas de mettre le
Bon j'ai trouvé une solution dans je vous la montre ca marche a peu près.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Dim idfichier As Integer idfichier = FreeFile Open "c:\monfichier.mp3 For Binary As #idfichier Dim record As String record = Space(2000) 'prent les 2000 premier caractere Get #idfichier, , record Close #idfichier '2 Choix possible pour trouvé le n° de piste If (InStr(1, record, "TRK") <> 0) Then record = Left(Right(record, Len(record) - InStr(1, record, "TRK") + 1), 14) ElseIf (InStr(1, record, "TRCK") <> 0) Then record = Left(Right(record, Len(record) - InStr(1, record, "TRCK") + 1), 14) Else record = "pas de piste trouvé" End If '3 Choix de caractere pour séparé le n° de piste les carractere 1 a 4 dans le tableau ASCII If (InStr(1, record, Chr(2)) <> 0) Then record = Replace(Right(record, Len(record) - InStr(1, record, Chr(2))), vbNullChar, "") ElseIf (InStr(1, record, Chr(3)) <> 0) Then record = Replace(Right(record, Len(record) - InStr(1, record, Chr(3))), vbNullChar, "") ElseIf (InStr(1, record, Chr(4)) <> 0) Then record = Replace(Right(record, Len(record) - InStr(1, record, Chr(4))), vbNullChar, "") ElseIf (InStr(1, record, Chr(1)) <> 0) Then record = Replace(Right(record, Len(record) - InStr(1, record, Chr(1))), vbNullChar, "") Else record = record End If n = 0 Do n = n + 1 Loop While IsNumeric(Left(record, n)) piste = Val(Left(record, n - 1))
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager