Vlc.DotNet.Wpf怎么循环播放本地视频

何止初见 2017-02-28 04:51:42
Vlc.DotNet.Wpf,我在播放结束事件里,重新播放改文件。但是画面一直停在结束的最后一个画面上,不能重新开始播放?哪位大牛指导一下怎么才能实现循环播放。
...全文
4328 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
准爵 2020-08-04
  • 打赏
  • 举报
回复 1
直接重新播是不行的,会死锁。库的git上提到了:

One of the most common issue reported is that Vlc.DotNet freezes under certain conditions.
Vlc.DotNet uses libvlc under the hood. When libvlc calls a code, it is running in libvlc's thread. In that thread, if you call libvlc code, the libvlc code will deadlock because it waits for your method to return.
You need to make sure that your method returns control to libvlc so that it can execute your request.
For example, let's say you want the video to loop, and you do something like this
public void MediaEndReached(object sender, EventArgs args)
{
this.MediaPlayer.Play("<another file>");
}
you will experience deadlocks.
Instead, do something like this:
public void MediaEndReached(object sender, EventArgs args)
{
ThreadPool.QueueUserWorkItem(_ => this.MediaPlayer.Play("<another file>"));
}
This ensures that your code is executed asynchronously on another thread, and control is correctly returned to libvlc.
准爵 2020-08-04
  • 打赏
  • 举报
回复
似乎只能在它的结束事件里重新播一遍
public void MediaEndReached(object sender, EventArgs args)
{
ThreadPool.QueueUserWorkItem(_ => this.MediaPlayer.Play("<another file>"));
}
心路Silence 2019-11-18
  • 打赏
  • 举报
回复
大佬问题解决了吗?求分享
C# 轰轰烈 2019-01-30
  • 打赏
  • 举报
回复
    sourceProvider.MediaPlayer.EndReached += MediaPlayer_EndReached;

private void MediaPlayer_EndReached(object sender, Vlc.DotNet.Core.VlcMediaPlayerEndReachedEventArgs e)
{
Task.Factory.StartNew(() => {
this.sourceProvider.Dispose();
//this.sourceProvider = null;
Application.Current.Dispatcher.BeginInvoke(new Action(() => {
this.sourceProvider = new VlcVideoSourceProvider(Application.Current.Dispatcher);
this.sourceProvider.CreatePlayer(libDirectory);
sourceProvider.MediaPlayer.Audio.Volume = 0;
this.sourceProvider.MediaPlayer.Play(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\" + PalyFileName2));
sourceProvider.PropertyChanged += SourceProvider_PropertyChanged1;
sourceProvider.MediaPlayer.EndReached += MediaPlayer_EndReached;
sourceProvider.MediaPlayer.VideoOutChanged += MediaPlayer_NewVideoOutChanged;
}));
});

}
zq1564171310 2017-05-27
  • 打赏
  • 举报
回复
myVlcControl.State == Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States.Ended
myVlcControl是你的VlcControl实例对象,检测一下在什么地方播放结束,播放下一个就行了,除此之外: Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States.Error播放错误 Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States.Playing正在播放 Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States.Stopped 停止播放状态 Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States.Paused 暂停状态 还有很多你自己看看需要什么,点之后看英文,慢慢摸索吧
何止初见 2017-03-01
  • 打赏
  • 举报
回复
没有,只有四个dll文件。
exception92 2017-03-01
  • 打赏
  • 举报
回复
引用 2 楼 HeZhiChuJian 的回复:
没有,只有四个dll文件。
那就根据方法的含义去理解测试了。
exception92 2017-02-28
  • 打赏
  • 举报
回复
没API文档么

8,735

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧