0

VB.NET 中的 VLC Player 似乎不会检测到播放结束,我做错了什么吗?

我的意图是使用“_MediaPlayerEndReached”让播放器移动到下一个视频,但是一旦视频播放完成,什么都不会发生,它就会停止(如下图所示)。

而不是移动到下一个视频,它只是保持这样:

仅供参考:用于测试的剪辑是免费的预告片。

在此处输入图像描述

代码:

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
4

3 回答 3

0

您不能在 EndReached() 事件中播放另一个媒体文件。最好的解决方案是在最后创建另一个线程,这个线程将在媒体的 REAL 结束之后播放新文件。与 MediaPlayer 用户控件相同。

如果您不知道如何创建新线程,这是最简单的方法:

thread = new Thread(() => while(VLC IS PLAYING) {}; PlayNewFile;  )); 
thread.Start();

我没有测试它,但这应该可以完成工作。

该线程正在等待 VLC 停止视频,然后播放下一个。

编辑:

看看这个:DMediaPlayer - 简单的 VLC 前端

并在这里阅读:.Net_Interface_to_VLC

于 2013-01-25T13:05:15.143 回答
0

我已经弄清楚了如何使用计时器。感谢所有帮助

代码:

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
于 2013-01-25T14:14:48.843 回答
0
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.playItem(0)
    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.playItem(0)
    End Sub
End Class

您必须通过新帖子这样做。如果您执行代码,它将重置所有第一次通过帖子的人。试试看好吗!新希捷

于 2013-12-26T03:23:41.580 回答