4 代码实现
命名空间既全局变量的引入,核心代码如下:
Imports System.Media
Public Class Form1
Inherits Windows.Forms.Form
Dim StartPoint As Single '复读开始点变量
Dim EndPoint As Single = AxWindowsMediaPlayer1.currentMedia.duration ‘复读结束点变量
Dim EndPoint As Single
Dim PlayFlag As Boolean = True '是否重复播放
Dim TipsFlag As Boolean = False '是否显示提示的标志
End Class
(1)“播放“按钮单击事件的核心代码
Private Sub LbPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LbPlay.Click
AxWindowsMediaPlayer1.Ctlcontrols.play() '播放
LbPause.Enabled = True
LbStop.Enabled = True
(2)“暂停“按钮单击事件的核心代码
Private Sub LbPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LbPause.Click
LbPause.Enabled = True
LbPlay.Enabled = True
AxWindowsMediaPlayer1.Ctlcontrols.pause() '暂停
End Sub
(3)“停止“按钮单击事件核心代码
Private Sub LbStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LbStop.Click
AxWindowsMediaPlayer1.Ctlcontrols.stop() '停止
LbPlay.Enabled = True
LbStop.Enabled = False
End Sub
(4)Time1控件的Tick事件核心代码
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TkProgress.Maximum = AxWindowsMediaPlayer1.currentMedia.duration '滑轨的最大值为媒体总得播放时间
|