本文介绍了libVLCSharp 无法创建 MediaList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在玩 libVLCSharp,我发现了一个有线行为.实际上,我创建媒体并使用 MediaPlayer 播放没有问题.但是,当我尝试从 MediaList 创建媒体时,它会中断并显示以下消息:
I'am playing arround with libVLCSharp and I found a wired behavior. Actually I have no problem creating a media and playing it with MediaPlayer. However when I try to create a Media from MediaList it breaks with the followig message:
无法在本机端执行实例化.确保你在你的电脑中安装了正确的 VideoLAN.LibVLC.[YourPlatform] 包平台特定项目
我想要实现的是使用 ":sout=#gather" 管道进行视频合并.
What I wanted to achive is video merging using ":sout=#gather" pipe.
我的代码非常基础:
Core.Initialize();
using (var libvlc = new LibVLC())
using (var mediaPlayer = new MediaPlayer(libvlc))
{
Media media1 = new Media(libvlc, @"C:\Temp\SampleVideo.mp4");
Media media2 = new Media(libvlc, @"C:\Temp\SampleVideo.mp4");
MediaList list = new MediaList(libvlc);
list.AddMedia(media1);
list.AddMedia(media2);
Media mediaList = new Media(list); <-- Error here
...
}
我的项目中使用了 2 个 nuget 包:
I have 2 nuget packages used in my project:
- LibVLCSharp v3.0.2 6 月 12 日
- VideoLAN.LibVLC.Windows v3.0.7 6 月 10 日
推荐答案
您希望为此使用 SetMedia,而不是 AddMedia.
You want to be using SetMedia for this, not AddMedia.
将媒体实例与此媒体列表实例相关联.
Core.Initialize();
using(var libVLC = new LibVLC())
{
var media1 = new Media(libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation);
var mediaList = new MediaList(libVLC);
mediaList.SetMedia(media1);
var media2 = new Media(mediaList);
}
这篇关于libVLCSharp 无法创建 MediaList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!