Vlc.DotNet.Wpf,我在播放結束事件里,重新播放改檔案。但是畫面一直停在結束的最后一個畫面上,不能重新開始播放?哪位大牛指導一下怎么才能實作回圈播放。
uj5u.com熱心網友回復:
沒API檔案么uj5u.com熱心網友回復:
沒有,只有四個dll檔案。uj5u.com熱心網友回復:
那就根據方法的含義去理解測驗了。
uj5u.com熱心網友回復:
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 暫停狀態
還有很多你自己看看需要什么,點之后看英文,慢慢摸索吧
uj5u.com熱心網友回復:
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;
}));
});
}
uj5u.com熱心網友回復:
大佬問題解決了嗎?求分享uj5u.com熱心網友回復:
似乎只能在它的結束事件里重新播一遍public void MediaEndReached(object sender, EventArgs args)
{
ThreadPool.QueueUserWorkItem(_ => this.MediaPlayer.Play("<another file>"));
}
uj5u.com熱心網友回復:
直接重新播是不行的,會死鎖。庫的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.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/21400.html
上一篇:關于智能化運維方面的一些問題
下一篇:中文路徑
