-
Notifications
You must be signed in to change notification settings - Fork 85
Home
欢迎来到 xZune.Vlc wiki!
xZune.Vlc 项目的参考文档与提示.
Welcome to the xZune.Vlc wiki!
The reference documentation and tips on xZune.Vlc project.
xZune.Vlc 是一个 LibVlc 封装库的 .NET 实现,封装了大部分的 LibVlc 的功能,该项目主要是为了寻求一个在 WPF 上使用 Vlc 的完美的解决方案,xZune.Vlc 提供一个原生的 WPF 播放控件(xZune.Vlc.Wpf),该控件采用 InteropBitmap 与共享内存进行播放视频,是一个原生的 WPF 控件,不存在 HwndHost 的空域问题.
xZune.Vlc is an LibVlc solution for .NET, it has encapsulated most of functionalities of LibVlc. This project >aims to find a perfect solution for using Vlc on WPF. xZune.Vlc provides an native WPF control(xZune.Vlc.Wpf), >this control achieves video playback by utilizing InteropBitmap and shared memory. Since it’s a native WPF >control, it doesn't suffer from HwndHost’s airspace issue.
在您的项目中快速使用 xZune.Vlc:
Quick start xZune.Vlc in your project:
01.在项目中添加对 xZune.Vlc 的程序集的引用。
01.Add the references of xZune.Vlc to your project.
xZune.Vlc.dll
xZune.Vlc.Wpf.dll
02.在项目的属性中设置 LibVlc 库的目录。
02.Set the path of LibVlc in properties of your project.
在$(Your Project)\Properties\AssemblyInfo.cs
中添加 VlcSettingsAttribute。
Add a VlcSettingsAttribute in $(Your Project)\Properties\AssemblyInfo.cs
.
//设置 LibVlc 的目录
//Set the path of LibVlc
[assembly: VlcSettings(@"..\..\..\LibVlc")]
//设置 LibVlc 初始化时的选项
//Set the path and options of LibVlc
[assembly: VlcSettings(@"..\..\..\LibVlc", "-I", "dummy", "--ignore-config", "--no-video-title" )]
参考:
See:
https://github.com/higankanshi/xZune.Vlc/blob/master/xZune.Vlc.Wpf.Sample/Properties/AssemblyInfo.cs
03.在 Xaml 中加入 VlcPlayer 控件。
03.Add the VlcPlayer Control in your Xaml
<wpf:VlcPlayer xmlns:wpf="clr-namespace:xZune.Vlc.Wpf;assembly=xZune.Vlc.Wpf" x:Name="vlcPlayer"/>
04.载入媒体并播放。
04.Load and Play the media.
vlcPlayer.LoadMedia(@"C:\VlcTest.mp4"); //载入本地文件 Load a local file
//vlcPlayer.LoadMedia(@"H:\"); //载入DVD光盘 Load a DVD
//vlcPlayer.LoadMedia(new Uri("http://127.0.0.1")); //载入网络流 Load a Network Stream
vlcPlayer.Play(); //播放媒体 Play the media
05.停止媒体与释放资源。
05.Stop the media and Release the resources.
vlcPlayer.Stop()
可以用于停止媒体的播放。
vlcPlayer.Stop()
used for stop the Player.
VlcPlayer.Stop();
VlcPlayer.Play(); // 重载媒体。 Replay media.
可以在程序结束时调用vlcPlayer.Dispose()
释放所有资源。
You can call the vlcPlayer.Dispose()
to release the resource when you exit.
06.为音频输出使用均衡器(需要 LibVlc 2.2.0 以上)。
06.Add equalizer for audio(Need LibVlc 2.2.0 and higher).
使用 AudioEqualizer 为音频提供均衡器,并提供 18 种预置均衡器与 10 个可自定义放大数值的频带。
Now we can use AudioEqualizer to provide equalizer for VlcPlayer, have 18 preset equalizers and 10 frequency bands.
//使用预置的均衡器设置初始化均衡器。
//use preset equalizer setting to initilaize AudioEqualizer.
AudioEqualizer ae = new AudioEqualizer(PresetAudioEqualizerType.Classical);
Player.AudioEqualizer = ae;
//使用默认设置初始化均衡器,并为 10 个频带赋值。
//use default setting to initilaize AudioEqualizer and set every frequency bands.
AudioEqualizer ae = new AudioEqualizer();
ae.Preamp = 12;
ae[0] = -1.11022E-15f;
ae[1] = -1.11022E-15f;
ae[2] = -1.11022E-15f;
ae[3] = -1.11022E-15f;
ae[4] = -1.11022E-15f;
ae[5] = -1.11022E-15f;
ae[6] = -7.2f;
ae[7] = -7.2f;
ae[8] = -7.2f;
ae[9] = -9.6f;
Player.AudioEqualizer = ae;
注意(Note):
xZune.Vlc.VlcMediaPlayer
不会引用均衡器实例,仅会复制其值,但是 AudioEqualizer 提供了属性变更通知,你可以使用其属性变更事件来重新设置均衡器。
xZune.Vlc.Wpf.VlcPlayer
会引用均衡器实例,并且监听了当前均衡器的属性变更事件,当当前均衡器有变更会自动的为 VlcMediaPlayer 重新设置均衡器。The
xZune.Vlc.VlcMediaPlayer
will not keep a reference to the supplied equalizer so you need set it again after you changed some value ofAudioEqualizer
, we provide PropertyChanged event forAudioEqualizer
you can use this to reset equalizer.
ThexZune.Vlc.Wpf.VlcPlayer
will keep a reference to the supplied equalizer, when you changed some value ofAudioEqualizer
, it will auto reset equalizer forVlcMediaPlayer
.
07.循环播放视频。
07.loop the media.
通过设置 EndBehavior 来设置当媒体播放完毕后的动作,支持 Nothing,Stop,Repeat 三种模式。
当设置为 Nothing 时,会什么都不做,屏幕仍然会显示最后一帧的画面,你需要先将播放器停止才能重新播放视频。
当设置为 Stop 时,会自动停止视频,屏幕会被清空,并且可以直接使用播放方法重新播放视频,这是默认的行为。
当设置为 Repeat 时,会自动的重新播放视频。
You can set the EndBehavior property to set behavior when media ended. Support Nothing,Stop,Repeat mode.
If you set it to Nothing, player will do nothing after media ended, you need stop it, and you can play again.
If you set it to Stop, player will set to stop.
If you set it to Repeat, player will atuo play again media.
08.特殊的 VLC 功能。
08.Some other extension for VLC.
xZune.Vlc 使用了某些 VLC 的拓展功能,我们目前提供 LibVlc(2.2.0-xZune) 32bit 版本。如果您需要在更低或者更高的 VLC 版本上使用 xZune.Vlc,您可能需要自己编译 VLC for xZune.Vlc,以保证 xZune.Vlc 拓展功能可用。
xZune.Vlc has used some "Expansions" for VLC, we are providing LibVlc(2.2.0-xZune) 32bit version now.But you want to use xZune.Vlc with later or lower version,you could need compile VLC for xZune.Vlc by yourself,to ensure that the expansions are available.
查看 Compile VLC for xZune.Vlc 来获取编译 xZune 专用的 VLC 教程。
See Compile VLC for xZune.Vlc to get some infomation about compile VLC for xZune.