
07-03-2006, 08:10
|
|
|
|
חבר מתאריך: 12.08.04
הודעות: 993
|
|
בס"ד
זה מה שמצאתי בVB
קוד PHP:
Public Type ptID3 Title As String Artist As String Album As String Year As String Comment As String Genre As Variant GenreName As String Lyrics As String Lyrics3Tag As Boolean ID3v1Tag As Boolean End Type
Public Function ReadFile_Tags(filename As String) As ptID3
On Error GoTo errorhandler Dim iTemp As Integer Dim newGenre As String
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' ' use the filename to get ID3 info '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' Dim lngFilesize As Long Dim fn As Integer Dim Tag1 As ID3v1Tag Dim LyricEndID As String * 6 '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' ' Open the file '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''
fn = FreeFile Open filename For Binary As #fn 'Open the file so we can read it lngFilesize = LOF(fn) 'Size of the file, in bytes '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' ' Check for an ID3v1 tag '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' 'ID3v1 tag Get #fn, lngFilesize - 127, Tag1.id If Tag1.id = "TAG" Then 'If "TAG" is present, then we have a valid ID3v1 tag and will extract all available ID3v1 info from the file Get #fn, , Tag1.Title 'Always limited to 30 characters Get #fn, , Tag1.Artist 'Always limited to 30 characters Get #fn, , Tag1.Album 'Always limited to 30 characters Get #fn, , Tag1.Year 'Always limited to 4 characters Get #fn, , Tag1.Comment 'Always limited to 30 characters Get #fn, , Tag1.Genre 'Always limited to 1 byte (?) HasID3v1Tag = True ReadFile_Tags.Title = Replace(Trim(Tag1.Title), Chr(0), "") ReadFile_Tags.Artist = Replace(Trim(Tag1.Artist), Chr(0), "") ReadFile_Tags.Album = Replace(Trim(Tag1.Album), Chr(0), "") ReadFile_Tags.Year = Replace(Trim(Tag1.Year), Chr(0), "") ReadFile_Tags.Comment = Trim(Replace(Trim(Tag1.Comment), Chr(0), "")) ReadFile_Tags.Genre = Tag1.Genre '// si no hay nada poner default 'Other' Populate_Genres If Trim(Tag1.Genre) = "" Then iTemp = 12 Else iTemp = CInt(Tag1.Genre) If iTemp <= 0 Then iTemp = 1 Else iTemp = iTemp * 22 newGenre = Trim$(Mid$(gsGenres, iTemp, 22)) If Trim(newGenre) = "" Then newGenre = "Other" ReadFile_Tags.GenreName = newGenre gsGenres = "" Else
HasID3v1Tag = False End If ReadFile_Tags.ID3v1Tag = HasID3v1Tag 'lyrics3 tag If HasID3v1Tag = True Then Get #fn, lngFilesize - 136, LyricEndID 'look for a lyrics 3 tag Else Get #fn, lngFilesize - 8, LyricEndID 'look for a lyrics 3 tag End If
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' ' Close the file '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''' Close 'lyrics3 tag? If LyricEndID = "LYRICS" Then 'got one, go get it HasLyrics3Tag = GetLyrics3Tag(filename) ReadFile_Tags.Lyrics = sLyrics ReadFile_Tags.Lyrics3Tag = HasLyrics3Tag Else HasLyrics3Tag = False ReadFile_Tags.Lyrics3Tag = False End If Exit Function errorhandler: err.Clear Close End Function
|