Thứ Năm, 13 tháng 9, 2007

Read MP3 header information and read/write the ID3v1 tag

Dim objMP3Info As New _
Monotic.Multimedia.MP3.MP3Info
With ListView1
''' Set the filename property
objMP3Info.Filename = "c:\test.mp3"

''' Add the header information to a listview
.Add("Filesize").SubItems.Add(objMP3Info.Filesize & " Byte")
.Add("SamplingRateFrequency").SubItems.Add _
(objMP3Info.SamplingRateFrequency & " Hz")
.Add("Padding").SubItems.Add(objMP3Info.Padding & " Bytes")
.Add("Private").SubItems.Add(objMP3Info.PrivateBit)
.Add("Copyright").SubItems.Add(objMP3Info.Copyright)
.Add("OriginalBit").SubItems.Add(objMP3Info.OriginalBit)
.Add("Bitrate").SubItems.Add(objMP3Info.Bitrate & " bps")
.Add("FrameSamples").SubItems.Add(objMP3Info.FrameSamples)
.Add("FrameSize").SubItems.Add(objMP3Info.FrameSize & " Byte")
.Add("Length").SubItems.Add(objMP3Info.Length & " s ("
& Int(objMP3Info.Length / 60) & ":" & _
objMP3Info.Length Mod 60 & " m)")
.Add("HeaderPosition").SubItems.Add(objMP3Info.HeaderPosition)
.Add("VBRScale").SubItems.Add(objMP3Info.VBRScale)

Select Case objMP3Info.MPEGVersion
Case MP3.MPEGVersionEnum.MPEG1
.Add("MPEGType").SubItems.Add("MPEG 1")
Case MP3.MPEGVersionEnum.MPEG2
.Add("MPEGType").SubItems.Add("MPEG 2")
Case MP3.MPEGVersionEnum.MPEG25
.Add("MPEGType").SubItems.Add("MPEG 2.5")
End Select

Select Case objMP3Info.Layer
Case MP3.LayerEnum.LayerI
.Add("Layer").SubItems.Add("Layer I")
Case MP3.LayerEnum.LayerII
.Add("Layer").SubItems.Add("Layer II")
Case MP3.LayerEnum.LayerIII
.Add("Layer").SubItems.Add("Layer III")
End Select

Select Case objMP3Info.Protection
Case MP3.ProtectionEnum.None
.Add("Protection").SubItems.Add("None")
Case MP3.ProtectionEnum.CRC
.Add("Protection").SubItems.Add("By CRC")
End Select

Select Case objMP3Info.ChannelMode
Case MP3.ChannelModeEnum.DualChannel
.Add("ChannelMode").SubItems.Add("Dual Channel")
Case MP3.ChannelModeEnum.JointStereo
.Add("ChannelMode").SubItems.Add("Joint Stereo")
Case MP3.ChannelModeEnum.SingleChannel
.Add("ChannelMode").SubItems.Add("Single Channel")
Case MP3.ChannelModeEnum.Stereo
.Add("ChannelMode").SubItems.Add("Stereo")
End Select

Select Case objMP3Info.Emphasis
Case MP3.EmphasisEnum.CCIT
.Add("Emphasis").SubItems.Add("CCIT")
Case MP3.EmphasisEnum.MS5015
.Add("Emphasis").SubItems.Add("50/15 ms")
Case MP3.EmphasisEnum.None
.Add("Emphasis").SubItems.Add("None")
End Select

Select Case objMP3Info.Encoding
Case MP3.EncodingEnum.CBR
.Add("Encoding").SubItems.Add("CBR")
Case MP3.EncodingEnum.VBR
.Add("Encoding").SubItems.Add("VBR")
End Select

''' Add the ID3v1 tag information to a listview
If (objMP3Info.ID3v1Tag.TagAvailable) Then
.Add("ID3 Title").SubItems.Add _
(objMP3Info.ID3v1Tag.Title)
[...]
End If

''' Update the tag
objMP3Info.ID3v1Tag.Title = "Another title"
objMP3Info.ID3v1Tag.Update()

End With

Không có nhận xét nào: