當前位置:編程學習大全網 - 源碼下載 - vb如何實現mp3的波形效果

vb如何實現mp3的波形效果

包含了控件DMC,源碼下載地址如下:

http://afei.name/upload/dmc.rar

源碼如下:

Option Explicit

Dim o_AD As IBasicAudio

Dim o_VW As IVideoWindow

Dim o_FM As FilgraphManager

Dim o_Pos As IMediaPosition

Dim o_Event As IMediaEvent

Dim o_Filter As IFilterInfo

Dim Url As String

Private Sub DMC1_ErrorOccurred(ByVal where As String, ByVal info As String)

Debug.Print where & "," & info

End Sub

Private Sub DMC1_URLStreamStoped(ByVal paused As Boolean)

Debug.Print "URL-" & paused

End Sub

Private Sub Form_Load()

DMC1.DeviceToUse = 1

DMC1.InitBASS Me.hWnd, 44100, True, False

DMC1.BufferLenInSeconds = 1

DMC1.StreamPan = 0

DMC1.OpenURLStream "http://afei.name/media/california.mp3" '播放網絡歌曲

DMC1.OpenStream App.Path & "\music.mp3" '播放本地歌曲

picBox.ScaleTop = picBox.Height

picBox.ScaleHeight = -picBox.Height

DMC1.PlayURLStream

End Sub

Private Sub Form_Unload(Cancel As Integer)

If DMC1.URLStreamIsActive = True Then

DMC1.CloseStream

End If

DMC1.TerminateBASS

End Sub

Private Sub Timer2_Timer()

Dim intData(1000) As Integer, i As Integer

Dim X As Long, h As Long, TopN As Integer

If DMC1.URLStreamIsActive Or DMC1.StreamIsActive Then

If DMC1.URLStreamIsActive Then

Me.Caption = DMC1.URLStreamPosInSeconds & "/" & DMC1.URLStreamLenInSeconds

DMC1.URLStreamData intData, 1000

ElseIf DMC1.StreamIsActive Then

Me.Caption = DMC1.StreamPosInSeconds & "/" & DMC1.StreamLenInSeconds

DMC1.StreamData intData, 1000

End If

picBox.Cls

For i = 0 To 500 Step 2

h = ((intData(i) + 32768) / 65535 * picBox.Height)

X = picBox.Width * i / 500

If i = 0 Then picBox.PSet (0, h)

picBox.Line -(X, h), vbRed

Next

For i = 1 To 500 Step 2

h = ((intData(i) + 32768) / 65535 * picBox.Height)

X = picBox.Width * i / 500

If i = 1 Then picBox.PSet (0, h)

picBox.Line -(X, h), vbBlue

Next

End If

picBox.Refresh

End Sub

  • 上一篇:Go社區源代碼
  • 下一篇:docker在web開發中得使用流程是怎樣的
  • copyright 2024編程學習大全網