WPF封装VLC播放器控件(方式一:VideoPlayer控制Winform窗体句柄)

本文介绍如何在WPF中使用Vlc播放器控件,通过封装实现视频播放、暂停、快进等操作。提供了相关插件下载链接、自定义控件源码及主窗体调用逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

RunnerDNA

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值