永发信息网

vb如何实现mp3的波形效果

答案:1  悬赏:0  手机版
解决时间 2021-02-03 13:04
  • 提问者网友:像風在裏
  • 2021-02-03 01:33
vb如何实现mp3的波形效果
最佳答案
  • 五星知识达人网友:琴狂剑也妄
  • 2021-02-03 01:57
包含了控件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
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯