Hi,
If you don`t use a Playlist then you will need to use the AxWindowsMediaPlayer1.PlayStateChange event to detect when the media ends so you can start the next video.
Being you can`t start the next video from within the PlayStateChange event you will need to use a Timer with a small delay like 200 milliseconds and in the Tick event you start the next video.
I take it you want a loop effect so in this example i check if it is the last video that ended and if it is then i start the first video again.
You can test the code in a new Form project with 1 Button and 1 AxWindowsMediaPlayer added to the form. You will also need a folder in the Debug folder named "Videos" with your video files in it.
- Public Class Form1
-
Private WithEvents Tmr As New Timer With {.Interval = 200}
-
Private VideoFiles As New List(Of String)
-
Private VideoPath As String = IO.Path.Combine(Application.StartupPath, "Videos")
-
Private PlayingIndex As Integer = 0
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
For Each fn As String In IO.Directory.GetFiles(VideoPath, "*.mp4")
-
VideoFiles.Add(fn) 'add all the video file names to the List
-
Next
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
PlayingIndex = 0 'if you want it to start at the first video every timr this button is clicked
-
AxWindowsMediaPlayer1.URL = VideoFiles(PlayingIndex)
-
End Sub
-
-
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
-
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then
-
Tmr.Start()
-
End If
-
End Sub
-
-
Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick
-
Tmr.Stop()
-
PlayingIndex += 1
-
If PlayingIndex > VideoFiles.Count - 1 Then PlayingIndex = 0 'if its the last video then start at the first video again
-
AxWindowsMediaPlayer1.URL = VideoFiles(PlayingIndex)
-
AxWindowsMediaPlayer1.Ctlcontrols.play()
-
End Sub
-
End Class
-