Author |
Message |
Juan #1 / 5
|
 mp3 files
How can I read the name of the song and the artists name of an mp3 file from code? Thanks Juan
|
Sat, 31 Jan 2004 04:53:05 GMT |
|
 |
Howard Henry Schlunde #2 / 5
|
 mp3 files
Look for a ID3v1 tag on the MP3. If present, read the data from it. If not present, look for an ID3v2 tag on the MP3 and get your data out of it. If neither are present, then you probably have to make a guess by parsing the MP3's filename. Below is some code I wrote for ID3v1 tags, test it by just dragging an MP3 onto the Form from within Windows. See the ID3v1 specification at [ http://www.id3.org/id3v1.html ]. Also see the ID3v2 specification at [ http://www.id3.org/ ]. Option Explicit Private Sub Form_Load() Me.OLEDropMode = 1 'Enable OLE Drops End Sub Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Dim TagData(0 To 127) As Byte Dim UnicodeTag As String, SongTitle As String, SongAuthor As String If Data.GetFormat(vbCFFiles) Then If Len(Data.Files.Item(1)) > 4 Then If LCase(Right$(Data.Files.Item(1), 4)) = ".mp3" And FileLen(Data.Files.Item(1)) > 128 Then Open Data.Files(1) For Binary As #1 Get #1, (LOF(1) - 127), TagData Close #1 If TagData(0) = Asc("T") And TagData(1) = Asc("A") And TagData(2) = Asc("G") Then 'And TagData(0) = 32 Then 'Cool, we have a 'TAG', let's use it UnicodeTag = StrConv(TagData, vbUnicode) SongTitle = Trim(Mid(UnicodeTag, 4, 30)) SongAuthor = Trim(Mid(UnicodeTag, 34, 30)) MsgBox SongAuthor & " -- " & SongTitle Else Debug.Print "No ID3v1 Tag: " & Data.Files.Item(1) End If End If End If End If End Sub Howard Henry Schlunder Quote:
> How can I read the name of the song and the artists name of an mp3 file from > code? > Thanks > Juan
|
Sat, 31 Jan 2004 07:58:29 GMT |
|
 |
Frank Ad #3 / 5
|
 mp3 files
On Mon, 13 Aug 2001 23:58:29 GMT, "Howard Henry Schlunder"
Also , some older MP3s had information on the end of the file (last couple of hundres bytes), i don't think these were ID3x infos though, they look like something that was just tagged on (kind of a kludge) ? Quote: >This is a multi-part message in MIME format. >------=_NextPart_000_12A7_01C12419.26E552B0 >Content-Type: text/plain; > charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable >Look for a ID3v1 tag on the MP3. If present, read the data from it. If = >not present, look for an ID3v2 tag on the MP3 and get your data out of = >it. If neither are present, then you probably have to make a guess by = >parsing the MP3's filename. Below is some code I wrote for ID3v1 tags, = >test it by just dragging an MP3 onto the Form from within Windows. See = >the ID3v1 specification at [ http://www.id3.org/id3v1.html ]. Also see = >the ID3v2 specification at [ http://www.id3.org/ ]. =20 >Option Explicit >Private Sub Form_Load() > Me.OLEDropMode =3D 1 'Enable OLE Drops >End Sub >Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button = >As Integer, Shift As Integer, X As Single, Y As Single) >Dim TagData(0 To 127) As Byte >Dim UnicodeTag As String, SongTitle As String, SongAuthor As String > If Data.GetFormat(vbCFFiles) Then > If Len(Data.Files.Item(1)) > 4 Then > If LCase(Right$(Data.Files.Item(1), 4)) =3D ".mp3" And = >FileLen(Data.Files.Item(1)) > 128 Then > Open Data.Files(1) For Binary As #1 > Get #1, (LOF(1) - 127), TagData > Close #1 > If TagData(0) =3D Asc("T") And TagData(1) =3D Asc("A") And = >TagData(2) =3D Asc("G") Then 'And TagData(0) =3D 32 Then 'Cool, we have = >a 'TAG', let's use it > UnicodeTag =3D StrConv(TagData, vbUnicode) > SongTitle =3D Trim(Mid(UnicodeTag, 4, 30)) > SongAuthor =3D Trim(Mid(UnicodeTag, 34, 30)) > MsgBox SongAuthor & " -- " & SongTitle > Else > Debug.Print "No ID3v1 Tag: " & Data.Files.Item(1) > End If > End If > End If > End If >End Sub >Howard Henry Schlunder
>> How can I read the name of the song and the artists name of an mp3 = >file from >> code? >>=20 >> Thanks >>=20 >> Juan >------=_NextPart_000_12A7_01C12419.26E552B0 >Content-Type: text/html; > charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ><HTML><HEAD> ><META http-equiv=3DContent-Type content=3D"text/html; = >charset=3Diso-8859-1"> ><META content=3D"MSHTML 5.50.4208.1700" name=3DGENERATOR> ><STYLE></STYLE> ></HEAD> ><BODY> ><DIV><FONT face=3DArial size=3D2>Look for a ID3v1 tag on the MP3. = >If present,=20 >read the data from it. If not present, look for an ID3v2 tag on = >the MP3=20 >and get your data out of it. If neither are present, then you = >probably=20 >have to make a guess by parsing the MP3's filename. Below is some = >code I=20 >wrote for ID3v1 tags, test it by just dragging an MP3 onto the Form from = >within=20 >Windows. See the ID3v1 specification at [ </FONT><A=20 >href=3D"http://www.id3.org/id3v1.html"><FONT face=3DArial=20 >size=3D2>http://www.id3.org/id3v1.html</FONT></A><FONT face=3DArial=20 >size=3D2> ]. Also see the ID3v2 specification at [ </FONT><A=20 >href=3D"http://www.id3.org/"><FONT face=3DArial=20 >size=3D2>http://www.id3.org/</FONT></A><FONT face=3DArial = >size=3D2> ]. =20 ></FONT></DIV> ><DIV noWrap><PRE><FONT face=3D"Courier New" size=3D3> ><FONT size=3D2><FONT color=3D#0000ff>Option</FONT> <FONT = >color=3D#0000ff>Explicit</FONT> ><FONT color=3D#0000ff>Private</FONT> <FONT color=3D#0000ff>Sub</FONT> = >Form_Load() > Me.OLEDropMode =3D 1 <FONT color=3D#008200>'Enable OLE Drops</FONT> ><FONT color=3D#0000ff>End</FONT> <FONT color=3D#0000ff>Sub</FONT> ><FONT color=3D#0000ff>Private</FONT> <FONT color=3D#0000ff>Sub</FONT> = >Form_OLEDragDrop(Data <FONT color=3D#0000ff>As</FONT> DataObject, Effect = ><FONT color=3D#0000ff>As</FONT> <FONT color=3D#0000ff>Long</FONT>, = >Button <FONT color=3D#0000ff>As</FONT> <FONT = >color=3D#0000ff>Integer</FONT>, Shift <FONT color=3D#0000ff>As</FONT> = ><FONT color=3D#0000ff>Integer</FONT>, X <FONT color=3D#0000ff>As</FONT> = ><FONT color=3D#0000ff>Single</FONT>, Y <FONT color=3D#0000ff>As</FONT> = ><FONT color=3D#0000ff>Single</FONT>) ><FONT color=3D#0000ff>Dim</FONT> TagData(0 <FONT = >color=3D#0000ff>To</FONT> 127) <FONT color=3D#0000ff>As</FONT> <FONT = >color=3D#0000ff>Byte</FONT> ><FONT color=3D#0000ff>Dim</FONT> UnicodeTag <FONT = >color=3D#0000ff>As</FONT> <FONT color=3D#0000ff>String</FONT>, SongTitle = ><FONT color=3D#0000ff>As</FONT> <FONT color=3D#0000ff>String</FONT>, = >SongAuthor <FONT color=3D#0000ff>As</FONT> <FONT = >color=3D#0000ff>String</FONT> > <FONT color=3D#0000ff>If</FONT> Data.GetFormat(vbCFFiles) <FONT = >color=3D#0000ff>Then</FONT> > <FONT color=3D#0000ff>If</FONT> Len(Data.Files.Item(1)) > 4 <FONT = >color=3D#0000ff>Then</FONT> > <FONT color=3D#0000ff>If</FONT> LCase(Right$(Data.Files.Item(1), = >4)) =3D ".mp3" <FONT color=3D#0000ff>And</FONT> = >FileLen(Data.Files.Item(1)) > 128 <FONT color=3D#0000ff>Then</FONT> > <FONT color=3D#0000ff>Open</FONT> Data.Files(1) <FONT = >color=3D#0000ff>For</FONT> <FONT color=3D#0000ff>Binary</FONT> <FONT = >color=3D#0000ff>As</FONT> #1 > <FONT color=3D#0000ff>Get</FONT> #1, (LOF(1) - 127), TagData > <FONT color=3D#0000ff>Close</FONT> #1 > <FONT color=3D#0000ff>If</FONT> TagData(0) =3D Asc("T") <FONT = >color=3D#0000ff>And</FONT> TagData(1) =3D Asc("A") <FONT = >color=3D#0000ff>And</FONT> TagData(2) =3D Asc("G") <FONT = >color=3D#0000ff>Then</FONT> <FONT color=3D#008200>'And TagData(0) =3D 32 = >Then 'Cool, we have a 'TAG', let's use it</FONT> > UnicodeTag =3D StrConv(TagData, vbUnicode) > SongTitle =3D Trim(Mid(UnicodeTag, 4, 30)) > SongAuthor =3D Trim(Mid(UnicodeTag, 34, 30)) > MsgBox SongAuthor & " -- " & SongTitle > <FONT color=3D#0000ff>Else</FONT> > <FONT color=3D#0000ff>Debug</FONT>.<FONT = >color=3D#0000ff>Print</FONT> "No ID3v1 Tag: " & Data.Files.Item(1) > <FONT color=3D#0000ff>End</FONT> <FONT color=3D#0000ff>If</FONT> > <FONT color=3D#0000ff>End</FONT> <FONT color=3D#0000ff>If</FONT> > <FONT color=3D#0000ff>End</FONT> <FONT color=3D#0000ff>If</FONT> > <FONT color=3D#0000ff>End</FONT> <FONT color=3D#0000ff>If</FONT> ><FONT color=3D#0000ff>End</FONT> <FONT color=3D#0000ff>Sub</FONT></FONT> ></FONT></PRE></DIV> ><DIV><FONT face=3DArial size=3D2>Howard Henry Schlunder</FONT></DIV> ><DIV><FONT face=3DArial size=3D2></FONT> </DIV> ><DIV><FONT face=3DArial size=3D2></FONT> </DIV> ><DIV><FONT face=3DArial size=3D2>"Juan" <</FONT><A=20
>in message=20 ></FONT><A href=3D"
>face=3DArial=20 >size=3D2>
>face=3DArial=20 >size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> How can I read = >the name of=20 >the song and the artists name of an mp3 file from<BR>> code?<BR>> = ><BR>>=20 >Thanks<BR>> <BR>> Juan<BR></FONT></BODY></HTML> >------=_NextPart_000_12A7_01C12419.26E552B0--
Regards, Frank.
|
Sat, 31 Jan 2004 10:55:01 GMT |
|
 |
Basto #4 / 5
|
 mp3 files
Type MP3F TagID As String*3 Title As String*30 Artist As String*30 Album As String*30 Year As String*4 Comment As String*30 End Type Sub GetMP3Info (myMP3File As String) Dim fnr As Integer, mMP3 as MP3F fnr=FreeFile Open myMP3File For Binary As fnr fNum = FreeFile Seek #fnr, LOF(fnr) - 127 Get #fNum, , mMP3.TagID If mMP3.TagID = "TAG" Then Get #fnr, , mMP3.Title Get #fnr, , mMP3.Artist Get #fnr, , mMP3.Album Get #fnr, , mMP3.Year Get #fnr, , mMP3.Comment End If Close #fnr End Sub
Quote: > How can I read the name of the song and the artists name of an mp3 file from > code? > Thanks > Juan
|
Sun, 01 Feb 2004 00:21:04 GMT |
|
 |
sa.. #5 / 5
|
 mp3 files
decided to enlighten us with : Quote: >On Mon, 13 Aug 2001 23:58:29 GMT, "Howard Henry Schlunder"
>Also , some older MP3s had information on the end of the file (last >couple of hundres bytes), i don't think these were ID3x infos though, >they look like something that was just tagged on (kind of a kludge) ?
ID3 version 1 placed a 128 byte tag at the end of the MP3. With ID3 version 2 and later, the information is placed at the front of the MP3. You can get the technical documents pertaining to ID3 from http://www.id3.org . J. Jeremiah D. Seitz Porch karaoke king and the guy who runs with 8< scissors >8 Omega Techware http://omegatechware.hypermart.net
|
Mon, 02 Feb 2004 02:34:55 GMT |
|
|
|