简单的vb程序,帮忙看一下!

lengfenghongyu 2003-11-22 02:43:54
请翻译下文并将其用C改造。传回翻译后的文件,和C主要语句。

Deciphering(判读) MP3 Tag information with Visual Basic

The Windows Media Player provides an easy, quick way to drop MP3 capability i
nto a Visual Basic application. However, once you have an MP3, you may have wonde
red how to read information about the song, such as the song title and artist's n
ame. If the MP3 file uses the most popular tag encryption, ID3, then you're in lu
ck. This standard stores the Tag information in the last 128 bytes of the file (T
ag: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 contai
ns information. If the file does contain Tag information, store the last 128 byte
s in a custom variable. After that,cycle through the MP3 file, extracting informa
tion as you go. The following procedure shows the code that extracts this informa
tion 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 th
e combobox.


=============================================================
...全文
29 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdudyfrom 2003-11-24
  • 打赏
  • 举报
回复
英文的大概意思是,用vb的ID3将song的file文件的最后128个字节标记起来!
sdudyfrom 2003-11-24
  • 打赏
  • 举报
回复
这段英文我帮你翻译出来了,但是C语言我不熟,等待高人来帮忙吧,兄弟!
sdudyfrom 2003-11-24
  • 打赏
  • 举报
回复
翻译英文就不麻烦大家了,光看一下中间的vb代码就可以了。

将这段vb的代码用c语言写出来!谢谢了!


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
planetike 2003-11-24
  • 打赏
  • 举报
回复
太长了点吧。
lengfenghongyu 2003-11-24
  • 打赏
  • 举报
回复
有请各位高人近来指点一下!!!!
lengfenghongyu 2003-11-22
  • 打赏
  • 举报
回复
麻烦大家了,帮忙看看吧!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧