VB.NET 中的 VLC Player 似乎无法检测到播放结束,我做错了什么吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14521928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VLC Player in VB.NET won't seem to detect end of playback, am I doing something wrong?
提问by Santa
VLC Player in VB.NET won't seem to detect end of playback, am I doing something wrong?
VB.NET 中的 VLC Player 似乎无法检测到播放结束,我做错了什么吗?
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).
我的意图是使用“_MediaPlayerEndReached”让播放器移动到下一个视频,但是一旦视频播放完成,什么也没有发生,它就会停止(如下图所示)。
Rather than moving onto next video it just stays like this:
而不是进入下一个视频,它只是保持这样:
FYI: Clips used for testing are free trailers.
仅供参考:用于测试的剪辑是免费的预告片。


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
采纳答案by Santa
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
回答by Guy P
You can't play another media file at the EndReached() event. The best solution is to create another thread at the end, and this thread will Play the new file, after the REAL end of the media. Same as MediaPlayer user control.
您无法在 EndReached() 事件中播放其他媒体文件。最好的解决方案是在末尾创建另一个线程,该线程将在媒体的 REAL 结束后播放新文件。与 MediaPlayer 用户控件相同。
If you don't know how to create new thread this is the easiest way:
如果您不知道如何创建新线程,这是最简单的方法:
thread = new Thread(() => while(VLC IS PLAYING) {}; PlayNewFile; ));
thread.Start();
I didn't test it, but this should do the work.
我没有测试它,但这应该可以完成工作。
The thread is waiting for the VLC to stop the video, and then play the next one.
线程正在等待 VLC 停止视频,然后播放下一个。
EDIT:
编辑:
check this out : DMediaPlayer - Simple VLC frontend
看看这个:DMediaPlayer - 简单的 VLC 前端
and read in here: .Net_Interface_to_VLC
并在此处阅读:.Net_Interface_to_VLC
回答by Vinh Phu
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
you must do so through the new posts. if you do your code, it will reset all doing their first going through the post. tries okay! New Seagate
你必须通过新职位这样做。如果你做你的代码,它会重置所有做他们第一次通过帖子的人。试试没问题!新希捷

