Clear
Local lcMP3File, laMP3Info(5)
Store [] To laMP3Info
lcMP3File = [d:\englishSong\rock dj.mp3]
If GetMP3Info( lcMP3File, @laMP3Info )
? [文件: ] + lcMP3File
? [歌曲: ] + laMP3Info(1)
? [歌手: ] + laMP3Info(2)
? [歌集: ] + laMP3Info(3)
? [年份: ] + laMP3Info(4)
? [备注: ] + laMP3Info(5)
Else
= MessageBox( [该文件没有包含媒体信息!] )
Endif
Local lcRetuStr, lnMicLength
lcRetuStr = SendMciString( [Open ]+lcMP3File+[ Alias MICTEMP] )
If Left(lcRetuStr,5)=[错误:]
= MessageBox(lcRetuStr, 0+16+0, [打开媒体文件错误])
Else
= SendMciString( [Set MICTEMP Time Format MilliSeconds])
&& 设置时间格式
lnMicLength = Val(SendMciString( [Status MICTEMP Length] )) && 取媒体长度
= SendMciString( [Close MICTEMP] )
? [时间: ] + allt(str(lnMicLength))+[ 毫秒]
Endif
Return
Function GetMP3Info ( tcMP3File, taMP3Info )
External Array taMP3Info
tcMP3File = iif(Type([tcMP3File])=[C], tcMP3File, [])
If Type([aLen(taMP3Info,1)])#[N]
Dime taMP3Info(5)
Else
If aLen(taMP3Info,1)#5
Dime taMP3Info(5)
Endif
Endif
If File(tcMP3File)
Local lcMP3Str, lnFHand
lnFHand = FOPEN( tcMP3File )
If lnFHand > 0
= FSEEK( lnFHand, -128, 2)
lcMP3Str = FREAD( lnFHand, 127 )
= FCLOSE( lnFHand )
If uppe(subs(lcMP3Str,1,3)) = [TAG]
lcMP3Str = subs(lcMP3Str,4)
taMP3Info(1) = allt(subs(lcMP3Str, 1,30))+chr(0)
taMP3Info(1) = allt( left(taMP3Info(1),at(chr(0),taMP3Info(1))-1) )
taMP3Info(2) = allt(subs(lcMP3Str,31,30))+chr(0)
taMP3Info(2) = allt( left(taMP3Info(2),at(chr(0),taMP3Info(2))-1) )
taMP3Info(3) = allt(subs(lcMP3Str,61,30))+chr(0)
taMP3Info(3) = allt( left(taMP3Info(3),at(chr(0),taMP3Info(3))-1) )
taMP3Info(4) = allt(subs(lcMP3Str,91, 4))+chr(0)
taMP3Info(4) = allt( left(taMP3Info(4),at(chr(0),taMP3Info(4))-1) )
taMP3Info(5) = allt(subs(lcMP3Str,95,30))+chr(0)
taMP3Info(5) = allt( left(taMP3Info(5),at(chr(0),taMP3Info(5))-1) )
Return .T.
Else
Return .F.
Endif
Else
Return .F.
Endif
Else
Return .F.
Endif
Endfunc
Function SendMciString( tcMCIcmd )
Declare integer mciSendString in WINMM String, String, integer,integer
Declare integer mciGetErrorString in WINMM integer, String, integer
lcRetStr = Space( 80)
lcErrStr = Space(256)
lnRetVal = mciSendString( tcMCIcmd, @lcRetStr, Len(lcRetStr), 0 )
If lnRetVal=0
Retu Trim(Strtran(lcRetStr,chr(0),""))
Else
= mciGetErrorString(lnRetVal,@lcErrStr,Len(lcErrStr))
Retu [错误: ]+Trim(Chrtran(lcErrStr,chr(0),""))
Endif
Endfunc