Search code examples
vb.netvisual-studio-2010media-playervlclibvlc

VLC Player in VB.NET won't seem to detect end of playback, am I doing something wrong?


VLC Player in VB.NET won't seem to detect end of playback, am I doing something wrong?

My intention was to use "_MediaPlayerEndReached" to make the player move onto the next video but instead once playback of a video completes nothing happens, it just stops (as in image below).

Rather than moving onto next video it just stays like this:

FYI: Clips used for testing are free trailers.

enter image description here

Code:

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        AxVLCPlugin21.playlist.items.clear()
        AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/The_Hobbit_Full_Length_Trailer_2_HD.mp4")
        AxVLCPlugin21.playlist.play()
    End Sub

    Private Sub AxVLCPlugin21_MediaPlayerEndReached(sender As Object, e As EventArgs) Handles AxVLCPlugin21.MediaPlayerEndReached
        AxVLCPlugin21.playlist.items.clear()
        AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/ShortestVid.avi")
        AxVLCPlugin21.playlist.play()
    End Sub
End Class

Solution

  • I've figured out how to do it, using a timer. Thanks for all help

    Code:

    Public Class Form1
        Dim Paused As Boolean = False
        Dim Started As Boolean = False
        Dim PlayedSecond As Boolean = True
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            PlayedSecond = False
            AxVLCPlugin21.playlist.items.clear()
            AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/The_Hobbit_Full_Length_Trailer_2_HD.mp4")
            AxVLCPlugin21.playlist.play()
            Started = True
        End Sub
    
        Sub playsecond()
                AxVLCPlugin21.playlist.items.clear()
                AxVLCPlugin21.playlist.add("file:///C:/Users/Adminx/Downloads/ShortestVid.avi")
                AxVLCPlugin21.playlist.play()
                PlayedSecond = True
                Started = False
        End Sub
    
        Private Sub AxVLCPlugin21_pause(sender As Object, e As EventArgs) Handles AxVLCPlugin21.pause
                Paused = True
        End Sub
    
        Private Sub IsFinished_Tick(sender As Object, e As EventArgs) Handles IsFinished.Tick
            If Not AxVLCPlugin21.playlist.isPlaying And Paused = False And Started = True And PlayedSecond = False Then
                playsecond()
                Started = True
            End If
        End Sub
    
        Private Sub AxVLCPlugin21_play(sender As Object, e As EventArgs) Handles AxVLCPlugin21.play
            Paused = False
        End Sub
    End Class