代码如下:
'播放器的接口
Public Interface AudioPlayerInterface AudioPlayer
Sub DoPlay()Sub DoPlay()
Sub DoStop()Sub DoStop()
Sub DoPause()Sub DoPause()
Property Source()Property Source() As String
End Interface
'采用Real Player API的播放器
Public Class RealAuidoPlayerClass RealAuidoPlayer
Implements AudioPlayer
Private mAP As AxRealAudioObjects.AxRealAudio
Public Sub New()Sub New(ByVal c As Control)
mAP = New AxRealAudioObjects.AxRealAudio
c.Controls.Add(mAP)
mAP.Visible = False
End Sub
Public Sub DoPause()Sub DoPause() Implements AudioPlayer.DoPause
mAP.DoPause()
End Sub
Public Sub DoPlay()Sub DoPlay() Implements AudioPlayer.DoPlay
mAP.DoPlay()
End Sub
Public Sub DoStop()Sub DoStop() Implements AudioPlayer.DoStop
mAP.DoStop()
End Sub
Public Property Source()Property Source() As_
String Implements AudioPlayer.Source
Get
Return mAP.Source
End Get
Set(ByVal Value As String)
mAP.Source = Value
End Set
End Property
End Class
'采用MS Media Player 的播放器类
Public Class MediaPlayerClass MediaPlayer
Implements AudioPlayer
Private mAP As WMPLib.WindowsMediaPlayerClass
Private ms As String
Public Sub New()Sub New()
mAP = New WMPLib.WindowsMediaPlayerClass
End Sub
Public Sub DoPause()Sub DoPause() Implements AudioPlayer.DoPause
mAP.pause()
End Sub
Public Sub DoPlay()Sub DoPlay() Implements AudioPlayer.DoPlay
mAP.play()
End Sub
Public Sub DoStop()Sub DoStop() Implements AudioPlayer.DoStop
mAP.stop()
End Sub
Public Property Source()Property Source() As_
String Implements AudioPlayer.Source
Get
Return mAP.URL
End Get
Set(ByVal Value As String)
mAP.URL = Value
mAP.pause()
End Set
End Property
End Class