|
Imports WMPLib
Public Class RunningSound
Private mHostingDataRow As DataRow
Private mSoundFilename As String
Private WithEvents mPlayer As New WindowsMediaPlayerClass
Private mPlayerControls As IWMPControls
Public ReadOnly Property SoundFilename() As String
Get
Return mSoundFilename
End Get
End Property
Public ReadOnly Property Player() As WindowsMediaPlayerClass
Get
Return mPlayer
End Get
End Property
Public ReadOnly Property PlayerControls() As IWMPControls
Get
Return mPlayer.controls
End Get
End Property
Public Sub New(ByVal HostingDataRow As DataRow, ByVal SoundsBasePath As String)
Dim SoundFilename As String = SoundsBasePath & "\" & HostingDataRow("Filename")
mHostingDataRow = HostingDataRow
mSoundFilename = SoundFilename
mPlayer.settings.autoStart = False
Dim m As IWMPMedia = mPlayer.newMedia(SoundFilename)
mPlayer.currentMedia = m
AddHandler mPlayer.PlayStateChange, AddressOf mPlayer_PlayStateChange
End Sub
Public Overrides Function ToString() As String
Dim result As String
Select Case mPlayer.playState
Case WMPPlayState.wmppsPlaying
result = "► "
Case WMPPlayState.wmppsPaused
result = "# "
Case Else
result = ""
End Select
If mPlayer.settings.getMode("LOOP") Then
result &= "∞"
End If
Return result
End Function
Private Sub mPlayer_PlayStateChange(ByVal NewState As Integer)
' To update the Status on grid
mHostingDataRow.Table.AcceptChanges()
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I was born in 1970.
My first computer experience dates back to early 80s, with a Sinclair ZX81.
From that time on, as many "friends" say, my IT-illness has increased year by year.
I graduated in Electronic Engineering and earned the following Microsoft certifications:
MCP, MCT, MCDBA, MCSD, MCAD, MCSD for .NET (early achiever).
I worked in IT as a developer, a teacher, a consultant, a technical writer, a technical leader.
IT knowledge applied to real life is my primary interest and focus.