时间: 2021-07-31 作者:daque
为了养护音乐者的版权,在mp3文献中有一段刻意保存版权证明的消息,稠密的mp3播放器软硬件都供给了窜改和读取mp3文献中湮没消息的功效,那么那些消息究竟保存在何处呢?怎样获得那些消息呢?正文将为大师供给获得mp3消息的模块。 开始,设置一个大众典型mp3tag如次: public type mp3tag artist as string ’artist 保存歌姬消息 album as string ’album 保存唱片专辑消息 title as string ’title 保存题目消息 year as string ’year 保存岁月消息 comments as string ’comments 存贮存注消息 genre as integer ’genre 保存音乐作风序列 end type 而后,设置一个获得mp3消息的因变量,它将归来那些消息,代码如次:public function getmp3tag(fname as string) as mp3tag dim artist as string dim album as string dim title as string dim year as string dim comments as string dim genre as integer if fname = "" then exit function if dir(fname) = "" then exit function dim filenum as integer filenum = freefile ’获得一个自在的文献号 dim strinput as string open fname for binary access read as filenum ’以二进制情势翻开文献 if lof(filenum) < 128 then close filenum exit function end if seek filenum, lof(filenum) - 127 ’把文献南针挪动到mp3消息处 strinput = space(3) get filenum, , strinput if strinput <> "tag" then ’即使没有创造消息标识,就封闭文献 close filenum goto done: end if strinput = space(30) get filenum, , strinput title = trim(strinput) strinput = space(30) get filenum, , strinput artist = trim(strinput) strinput = space(30) get filenum, , strinput album = trim(strinput) strinput = space(4) get filenum, , strinput year = trim(strinput) strinput = space(30) get filenum, , strinput comments = trim(strinput) strinput = space(1) get filenum, , strinput genre = asc(strinput)done: getmp3tag.title = title getmp3tag.artist = artist getmp3tag.album = album getmp3tag.year = year getmp3tag.year = comments if genre < 0 or genre > 254 then genre = 12 getmp3tag.genre = cint(genre) close filenumend function 提防:mp3文献对音乐的作风举行了控制,共254种。genre归来的不过mp3作风的序列号,简直还须要定位,在这边我把一切典型以常数情势列出,每个典型之间用"|"号隔绝。 private const sgenrematrix = "blues|classic rock|country|dance|disco|funk|grunge|" + _ "hip-hop|jazz|metal|new age|oldies|other|pop|r&b|rap|reggae|rock|techno|" + _ "industrial|alternative|ska|death metal|pranks|soundtrack|euro-techno|" + _ "ambient|trip hop|vocal|jazz+funk|fusion|trance|classical|instrumental|acid|" + _ "house|game|sound clip|gospel|noise|alt. rock|bass|soul|punk|space|meditative|" + _ "instrumental pop|instrumental rock|ethnic|gothic|darkwave|techno-industrial|electronic|" + _ "pop-folk|eurodance|dream|southern rock|comedy|cult|gangsta rap|top 40|christian rap|" + _ "pop/punk|jungle|native american|cabaret|new wave|phychedelic|rave|showtunes|trailer|" + _ "lo-fi|tribal|acid punk|acid jazz|polka|retro|musical|rock & roll|hard rock|folk|" + _ "folk/rock|national folk|swing|fast-fusion|bebob|latin|revival|celtic|blue grass|" + _ "avantegarde|gothic rock|progressive rock|psychedelic rock|symphonic rock|slow rock|" + _ "big band|chorus|easy listening|acoustic|humour|speech|chanson|opera|chamber music|" + _ "sonata|symphony|booty bass|primus|porn groove|satire|slow jam|club|tango|samba|folklore|" + _ "ballad|power ballad|rhythmic soul|freestyle|duet|punk rock|drum solo|a capella|euro-house|" + _ "dance hall|goa|drum & bass|club-house|hardcore|terror|indie|brit pop|negerpunk|polsk punk|" + _ "beat|christian gangsta rap|heavy metal|black metal|crossover|comteporary christian|" + _ "christian rock|merengue|salsa|trash metal|anime|jpop|synth pop" 把之上代码写到一个模块中(.bas),而后在窗体上介入5个textbox和1个combobox控件,个中5个textbox控件辨别用来表露一首mp3文献的以次消息:歌姬、岁月、唱片、指摘、题目,combobox控件用来表露歌曲的作风。再放一个command控件,其题目为“表露消息”,在它的click事变中介入以次代码: private sub command1_click() dim mp3tag as mp3tag mp3tag = getmp3tag ("c:\song.mp3") text1.text = mp3tag.artist text2.text = mp3tag.album text3.text = mp3tag.title text4.text = mp3tag.year text5.text = mp3tag.comments combo1.listindex = mp3tag.genre end sub 在窗体的加载进程中介入如次代码: private sub form_load() dim i as integer,genrearray() as string genrearray = split(sgenrematrix, "|") for i = lbound(genrearray) to ubound(genrearray) combo1.additem genrearray(i) next i end sub 之上代码在vb6 \win2000中尝试经过。