VFP 愛用者社區 首頁 VFP 愛用者社區
本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
 
 常見問題常見問題   搜尋搜尋   會員列表會員列表   會員群組會員群組   會員註冊會員註冊 
 個人資料個人資料   登入檢查您的私人訊息登入檢查您的私人訊息   登入登入

請問mp3的id3 tag

 
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區
上一篇主題 :: 下一篇主題  
發表人 內容
lcm



註冊時間: 2004-12-27
文章: 45


第 1 樓

發表發表於: 星期日 九月 04, 2005 11:29 am    文章主題: 請問mp3的id3 tag 引言回覆

請問各位大大,是否有人會讀取mp3 的id3 tag,謝謝。
回頂端
檢視會員個人資料 發送私人訊息
garfield
Site Admin


註冊時間: 2003-01-30
文章: 2160


第 2 樓

發表發表於: 星期日 九月 04, 2005 8:17 pm    文章主題: 引言回覆

這是VB語法, 請自己試著改成vfp
Deciphering MP3 Tag information with Visual Basic
The Windows Media Player provides an easy, quick way to drop MP3 capability into a Visual Basic application. However, once you have an MP3, you may have wondered how to read information about the song, such as the song title and artist's name. If the MP3 file uses the most popular tag encryption, ID3, then you're in luck. This standard stores the Tag information in the last 128 bytes of the file (Tag:3, Title:30, Artist:30, Album:30, Year:4, Comment:30, Genre:1)
To read this information, first open the MP3 file and grab the last 128 bytes. With ID3, the first three slots hold the string TAG if the file actually contains information. If the file does contain Tag information, store the last 128 bytes in a custom variable. After that, cycle through the MP3 file, extracting information as you go. The following procedure shows the code that extracts this information as well as creates several important variables to use later on:

Option Explicit
Private Type TagInfo
Tag As String * 3
Songname 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

Dim FileName As String
Dim CurrentTag As TagInfo

Private Sub Form1_Load()
Dim temp As String
On Error Resume Next

FileName = App.Path & "\myMP3.mp3"
Open FileName For Binary As #1
With CurrentTag
Get #1, FileLen(FileName) - 127, .Tag
If Not .Tag = "TAG" Then
label8.Caption = "No tag"
Close #1
Exit Sub
End If
Get #1, , .Songname
Get #1, , .artist
Get #1, , .album
Get #1, , .year
Get #1, , .comment
Get #1, , .genre
Close #1

txtTitle = RTrim(.Songname)
txtArtist = RTrim(.artist)
txtAlbum = RTrim(.album)
txtYear = RTrim(.year)
txtComment = RTrim(.comment)

Temp = RTrim(.genre)
txtGenreCode = Asc(Temp)
Combo1.ListIndex = CInt(txtGenreCode) - 1
End With
End Sub

Notice that the code has to handle the genre character a little differently. That's because ID3 stores this data as a single ASCII character. To match up the actual number with its corresponding description--say contained in a combobox--the procedure converts the ASCII to a number, and then looks up that number in thecombobox.

_________________
利用>>搜尋<<的功能會比問的還要快得到答案.
回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
lcm



註冊時間: 2004-12-27
文章: 45


第 3 樓

發表發表於: 星期日 九月 04, 2005 9:59 pm    文章主題: 引言回覆

謝謝,garfield 大大,我已將修改成下列程式。

procedure GetMp3Id3Tag
PARAMETERS mp3filename
fd=FOPEN(mp3Filename)
FSEEK(fd,-128, 2)
cString = FREAD(fd, 128)
FCLOSE(fd)
mp3Tag=SUBSTR(cString,1,3)
mp3title=SUBSTR(cString,4,30)
mp3artist=SUBSTR(cString,34,30)
mp3album=SUBSTR(cString,64,30 )
mp3year=SUBSTR(cString,94,4)
mp3comment =SUBSTR(cString,98,30)
mp3genre=SUBSTR(cString,128,1)
回頂端
檢視會員個人資料 發送私人訊息
從之前的文章開始顯示:   
發表新主題   回覆主題    VFP 愛用者社區 首頁 -> VFP 討論區 所有的時間均為 台北時間 (GMT + 8 小時)
1頁(共1頁)

 
前往:  
無法 在這個版面發表文章
無法 在這個版面回覆文章
無法 在這個版面編輯文章
無法 在這個版面刪除文章
無法 在這個版面進行投票
無法 在這個版面附加檔案
無法 在這個版面下載檔案


Powered by phpBB © 2001, 2005 phpBB Group
正體中文語系由 phpbb-tw 維護製作