TkProgress.Minimum = 0
TkProgress.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Dim m2, s2 As Integer
Dim m3, s3 As Integer
m2 = StartPoint \ 60 : s2 = StartPoint Mod 60
LbStart.Text = Format(m2, "00") & ";" & Format(s2, "00.0")
m3 = EndPoint \ 60 : s3 = EndPoint Mod 60
LbEnd.Text = Format(m3, "00") & ";" & Format(s3, "00.0")
LbTk.Left = TkProgress.Left + TkProgress.Width * StartPoint / AxWindowsMediaPlayer1.currentMedia.duration + 13 '设置控件X方向对应开始点时间
LbTk.Width = TkProgress.Width * (EndPoint - StartPoint) / AxWindowsMediaPlayer1.currentMedia.duration + 11
If AxWindowsMediaPlayer1.Ctlcontrols.currentPosition >= EndPoint Then
If PlayFlag = True Then
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = StartPoint '当播放位置到达末尾时,定位到复读起点循环播放
Else
AxWindowsMediaPlayer1.Ctlcontrols.stop()
End If
End If
LbMark.Text = ""
Static i As Integer
i = i + 1
If i = 5 Then
LbMark.Text = "●"
i = 0 '每五个时间单位闪烁一次
Dim d3, d4 As Integer
Dim s5, s4 As Integer
Dim m5, m4 As Integer
d3 = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition '当前播放进度
d4 = AxWindowsMediaPlayer1.currentMedia.duration '当前音频播放需要的总时间
m5 = d3 \ 60 : s5 = d3 Mod 60
m4 = d4 \ 60 : s4 = d4 Mod 60
LbProgress.Text = Format(m5, "00") & ":" & Format(s5, "00.0") & "/" & Format(m4, "00") & ":" & Format(s4, "00.0")
LbRate.Text = "速度" + (AxWindowsMediaPlayer1.settings.rate * 16).ToString + "kbs"
End If
End Sub
(5)滑块对应的鼠标拖动事件核心代码
Private Sub TkProgress_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TkProgress.Scroll
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = TkProgress.Value
End Sub
|