LabRat
LabRat

Reputation: 2014

Windows Media Player VB.net

I have a WMP in my vb.net project and I wanted to load the next media automatically after the first is finnished I did some research on googel and found the simple to understand code as per below.

      Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange

If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
            AxWindowsMediaPlayer1.URL = ("Test2.mp4")
            MessageBox.Show("Playing End")
        End If
End Sub

I however cant get it to automatically play the next (Test2.mp4) unless I have the messagebox pop-up. I discovered this purely by accident. However I dont want the Messagebox to pop-up everytime a new Mp4 file is ready to be played. Dose anybody know what is going on here and how I can fix this?

Upvotes: 1

Views: 1733

Answers (2)

I3efIzzgsw
I3efIzzgsw

Reputation: 83

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim oTask01 As Threading.Thread
    oTask01 = New Threading.Thread(AddressOf oStarting01)
    oTask01.Start()

    Dim omessagebox As MessageBox = Nothing
    omessagebox.Show("Playing End", "", MessageBoxButtons.OK)
    oTask01.Abort()

End Sub
Private Function oStarting01() As Byte
    While True
        System.Windows.Forms.SendKeys.SendWait(vbCr)
    End While
    Return 0
End Function
End Class

Hi, try with this code. It works. Diving more deeply in Windows system and subsystems is not an easy task, not at least for me. I hope you get what you were looking for for your software. Thank you very much. Happy codding!. :)

Upvotes: 1

I3efIzzgsw
I3efIzzgsw

Reputation: 83

Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As 
     System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) 
         Handles AxWindowsMediaPlayer1.PlayStateChange

     If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
         AxWindowsMediaPlayer1.URL = ("Test2.mp4")
        'MessageBox.Show("Playing End") 'This line was commented because is not neccesary in  this fragment of code
    End If
End Sub

Hi, if I have understood well to you, you wanted to supress the message box. It is got doing a comment's line with "'". I hope you like it and continue enjoying with computers and software. Thank you very much and happy codding. :)

Upvotes: 0

Related Questions