Vlc是一款优秀的开源播放器,支持众多音频与视频解码器及文件格式。这里采用WPF引用开源的Vlc相关插件(重新编译)封装了一个简单的视频播放器控件,实现视频播放、暂停、停止、快进、慢进、视频条、声音条、最大化等功能。
实现效果:
1、相关插件及资源文件放在了网盘,地址:https://pan.baidu.com/s/1Fyidxn3XgAJQAGL0RInVtQ 提取码:5alm
2、自定义控件UCVlcPlayer窗体源码
<UserControl x:Class="VlcPlayerWPFDemo.UCVlcPlayer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VlcPlayerWPFDemo"
xmlns:WinFormHost="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:WinFormControls="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
mc:Ignorable="d"
d:DesignHeight="440" d:DesignWidth="600">
<UserControl.Resources>
<Style x:Key="playButtonTemplate" TargetType="Button" >
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Width" Value="28"></Setter>
<Setter Property="Height" Value="28"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bor" BorderThickness="0">
<Border.Background>
<ImageBrush ImageSource="Resource/Play.png" Stretch="Fill"></ImageBrush>
</Border.Background>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="backButtonTemplate" TargetType="Button" >
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Width" Value="24"></Setter>
<Setter Property="Height" Value="24"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bor" BorderThickness="0">
<Border.Background>
<ImageBrush ImageSource="Resource/Back.png" Stretch="Fill"></ImageBrush>
</Border.Background>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="stopButtonTemplate" TargetType="Button" >
<Setter Property="Cursor" Value="Hand"></Setter>
<Se