Hi,
I have a problem with AxWindowsMediaPlayer for which I cannot find anything in the forum.
I am working on a mp3 player. When running from VisualStudio, everything works fine, including the "PlayStateChange" event of AxWindowsMediaPlayer. After I publish and install (on the same machine where I do the development), the installed version works fine, except that the "playstatechange" is completely inoperative. I included the whole parser of PlayStateChange for debug and log in a file. It never detects any activity in the player (no "Pause", "Play", and most importantly for me, no "MediaEnded").
I use Visual Basic 2010 Express.
The Media Player itself works fine. When I pause, stop, play, it does it correctly. It is just the PlayStateChange event that does not get detected for some reason.
Is this a know issue when publishing?
Any clue what could cause this?
Here is my "Playstatechange" code:
Public Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
' This Handler starts a timer when the song is over. The timer leaves some time for the application to complete a few misc tasks
' It also reports any new state of the layer for debugging
' Test the current state of the player, display a message for each state.
Select Case e.newState
Case 0 ' Undefined
System.Diagnostics.Debug.WriteLine("Undefined")
LogFile.WriteLine("Player: Undefined")
Case 1 ' Stopped
System.Diagnostics.Debug.WriteLine("Stopped")
LogFile.WriteLine("Player: Stopped")
Case 2 ' Paused
System.Diagnostics.Debug.WriteLine("Paused")
LogFile.WriteLine("Player: Paused")
Case 3 ' Playing
System.Diagnostics.Debug.WriteLine("Playing")
LogFile.WriteLine("Player: Playing")
Case 4 ' ScanForward
System.Diagnostics.Debug.WriteLine("ScanForward")
LogFile.WriteLine("Player: ScanForward")
Case 5 ' ScanReverse
System.Diagnostics.Debug.WriteLine("ScanReverse")
LogFile.WriteLine("Player: ScanReverse")
Case 6 ' Buffering
System.Diagnostics.Debug.WriteLine("Buffering")
LogFile.WriteLine("Player: Buffering")
Case 7 ' Waiting
System.Diagnostics.Debug.WriteLine("Waiting")
LogFile.WriteLine("Player: Waiting")
Case 8 ' MediaEnded
System.Diagnostics.Debug.WriteLine("MediaEnded")
LogFile.WriteLine("Player: MediaEnded")
' Start a timer with system.timer.timer
aTimer = New System.Timers.Timer(10000)
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Interval = 1000
aTimer.Enabled = True
' Change cursor to a wait curson, while tags are updated (if needed)
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Case 9 ' Transitioning
System.Diagnostics.Debug.WriteLine("Transitioning")
LogFile.WriteLine("Player: Transitioning")
Case 10 ' Ready
System.Diagnostics.Debug.WriteLine("Ready")
LogFile.WriteLine("Player: Ready")
Case 11 ' Reconnecting
System.Diagnostics.Debug.WriteLine("Reconnecting")
LogFile.WriteLine("Player: Reconnecting")
Case 12 ' Last
System.Diagnostics.Debug.WriteLine("Last")
LogFile.WriteLine("Player: Last")
Case Else
System.Diagnostics.Debug.WriteLine("Unknown State: " + e.newState.ToString())
LogFile.WriteLine("Player: Unknown State: " + e.newState.ToString())
End Select
End Sub
Thanks in advance for any help!
Benoit
I have a problem with AxWindowsMediaPlayer for which I cannot find anything in the forum.
I am working on a mp3 player. When running from VisualStudio, everything works fine, including the "PlayStateChange" event of AxWindowsMediaPlayer. After I publish and install (on the same machine where I do the development), the installed version works fine, except that the "playstatechange" is completely inoperative. I included the whole parser of PlayStateChange for debug and log in a file. It never detects any activity in the player (no "Pause", "Play", and most importantly for me, no "MediaEnded").
I use Visual Basic 2010 Express.
The Media Player itself works fine. When I pause, stop, play, it does it correctly. It is just the PlayStateChange event that does not get detected for some reason.
Is this a know issue when publishing?
Any clue what could cause this?
Here is my "Playstatechange" code:
Public Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
' This Handler starts a timer when the song is over. The timer leaves some time for the application to complete a few misc tasks
' It also reports any new state of the layer for debugging
' Test the current state of the player, display a message for each state.
Select Case e.newState
Case 0 ' Undefined
System.Diagnostics.Debug.WriteLine("Undefined")
LogFile.WriteLine("Player: Undefined")
Case 1 ' Stopped
System.Diagnostics.Debug.WriteLine("Stopped")
LogFile.WriteLine("Player: Stopped")
Case 2 ' Paused
System.Diagnostics.Debug.WriteLine("Paused")
LogFile.WriteLine("Player: Paused")
Case 3 ' Playing
System.Diagnostics.Debug.WriteLine("Playing")
LogFile.WriteLine("Player: Playing")
Case 4 ' ScanForward
System.Diagnostics.Debug.WriteLine("ScanForward")
LogFile.WriteLine("Player: ScanForward")
Case 5 ' ScanReverse
System.Diagnostics.Debug.WriteLine("ScanReverse")
LogFile.WriteLine("Player: ScanReverse")
Case 6 ' Buffering
System.Diagnostics.Debug.WriteLine("Buffering")
LogFile.WriteLine("Player: Buffering")
Case 7 ' Waiting
System.Diagnostics.Debug.WriteLine("Waiting")
LogFile.WriteLine("Player: Waiting")
Case 8 ' MediaEnded
System.Diagnostics.Debug.WriteLine("MediaEnded")
LogFile.WriteLine("Player: MediaEnded")
' Start a timer with system.timer.timer
aTimer = New System.Timers.Timer(10000)
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Interval = 1000
aTimer.Enabled = True
' Change cursor to a wait curson, while tags are updated (if needed)
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Case 9 ' Transitioning
System.Diagnostics.Debug.WriteLine("Transitioning")
LogFile.WriteLine("Player: Transitioning")
Case 10 ' Ready
System.Diagnostics.Debug.WriteLine("Ready")
LogFile.WriteLine("Player: Ready")
Case 11 ' Reconnecting
System.Diagnostics.Debug.WriteLine("Reconnecting")
LogFile.WriteLine("Player: Reconnecting")
Case 12 ' Last
System.Diagnostics.Debug.WriteLine("Last")
LogFile.WriteLine("Player: Last")
Case Else
System.Diagnostics.Debug.WriteLine("Unknown State: " + e.newState.ToString())
LogFile.WriteLine("Player: Unknown State: " + e.newState.ToString())
End Select
End Sub
Thanks in advance for any help!
Benoit