|
目录
LibVLCSharp.WPF简介
从vlc说起
LibVLC支持的平台:
平台LibVLC包Nuget地址最低操作系统版本WindowsVideoLAN.LibVLC.Windowshttps://www.nuget.org/packages/VideoLAN.LibVLC.Windows/Windows XPUWPVideoLAN.LibVLC.UWPhttps://www.nuget.org/packages/VideoLAN.LibVLC.UWP/Windows 10MacVideoLAN.LibVLC.Machttps://www.nuget.org/packages/VideoLAN.LibVLC.Mac/macOS 10.7AndroidVideoLAN.LibVLC.Androidhttps://www.nuget.org/packages/VideoLAN.LibVLC.Android/Android 2.3iOSVideoLAN.LibVLC.iOShttps://www.nuget.org/packages/VideoLAN.LibVLC.iOS/iOS 8.4tvOSVideoLAN.LibVLC.tvOShttps://www.nuget.org/packages/VideoLAN.LibVLC.tvOS/tvOS 10.2LinuxLinuxGuide:https://code.videolan.org/videolan/LibVLCSharp/-/blob/3.x/docs/linux-setup.md
- LibVLCSharp是对LibVLC的封装,相当于一个包装器,提供给C#开发人员使用LibVLC的功能。地址:https://code.videolan.org/videolan/LibVLCSharp
- LibVLCSharp.WPF是LibVLCSharp的WPF实现,封装了vlc:VideoView 这个UI控件,用来播放视频。 LibVLCSharp.WPF可以在.NETCoreApp 3.1 ;.NETFramework 4.6.1+; net6.0+运行时中使用。
虽然 LibVLCSharp 提供跨平台的解决方案,但是本文主要基于 Windows 平台来讨论。
vlc:VideoView基本使用
安装LibVLC
在使用LIibVLCSharp.WPF前必须先安装 LibVLC,否则会报如下错误:- //报错位置:实例化 LibVLC
- LibVLC _libvlc=new LibVLC();
- //Message:
- Failed to load required native libraries.
- Have you installed the latest LibVLC package from nuget for your target platform?
- Search paths include E:\code\WPF\APngApp\bin\Debug\net7.0-windows\libvlc\win-x64\libvlc.dll,E:\code\WPF\APngApp\bin\Debug\net7.0-windows\libvlc\win-x64\libvlccore.dll; E:\code\WPF\APngApp\bin\Debug\net7.0-windows\libvlc\win-x64\libvlc.dll,E:\code\WPF\APngApp\bin\Debug\net7.0-windows\libvlc\win-x64\libvlccore.dll; E:\code\WPF\APngApp\bin\Debug\net7.0-windows\libvlc.dll,
复制代码 LibVLC安装方式:
- 集成安装:LibVLC 已经打包成了一个package,放在了nuget上面,只需要在项目中安装此VideoLAN.LibVLC.Windows依赖就可以。nuget安装命令:NuGet\Install-Package VideoLAN.LibVLC.Windows
播放rtsp
新建 wpf 应用程序
引入命名空间
- xmlns:vlc="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
复制代码 xaml 代码
- <vlc:VideoView x:Name="video_main" >
- ......
- </vlc:VideoView>
复制代码 cs代码
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLC _libvlc = new LibVLC();
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video_main.Width = this.Width;
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video_main.Height = this.Height;
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video_main.MediaPlayer = player;
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//通过设置宽高比为窗体宽高可达到视频铺满全屏的效果
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>player.AspectRatio = this.Width + ":" + this.Height;
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "rtsp://user:password@192.168.1.120:554/ch1/main/av_stream";
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video_main.MediaPlayer.Play(media);
- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}
- }
复制代码 截图
概述
LibVLCSharp是对 vlc 的封装,而vlc本身就支持截图的功能,相应的LibVLCSharp也提供了一个 MediaPlayer.TakeSnapshot 的方法用来截图
调用该方法需要传递的参数:
- num:视频输出数量(通常第一个/仅一个为0)【直译过来的,这个参数具体什么意思尚不太清楚,当前是直接传0】
- filePath:图片文件存放路径,需要确保文件夹存在并有访问权限,如:D:\A\2.png
- width:图片的宽度
- height:图片的高度
- 若宽高都为0,则生成的图片为视频原始大小;若宽为0或者高为0,则生成的图片为视频原始的纵横比
代码示例
在页面添加一个按钮,在按钮点击事件中处理截图。
xaml:- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>
复制代码 cs:- private void snapshot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e){<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string dirPath = AppDomain.CurrentDomain.BaseDirectory+ "\\snapshot\";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//string dirPath = "D:\\A\";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string imgName = DateTime.Now.Ticks+ ".png";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string filePath = dirPath + imgName;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>bool r = this.video_main.MediaPlayer.TakeSnapshot(0, filePath, (uint)this.video_main.Width, (uint)this.video_main.Height);}
复制代码
- video_main 就是 VideoView 控件的name
vlc:VideoView进阶使用
空域问题
由于VideoView控件的实现原理是在window上面绑定一个前台窗体(ForegroudWindow),然后在ForegroudWindow中播放视频,所以当需要在window中添加其他控件(如:label,button<vlc:VideoView x:Name="video_main" >
......
</vlc:VideoView>)的时候不可以使用WPF原始的“并列”写法,而需要使用“层级”写法,即将需要展示的控件写在VideoView控件的"里面",他们形成父子级关系。
上述文字可能比较难以理解, 用代码来分析。首先通过编写如下代码,让视频播放起来:
xaml:- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label> <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>
复制代码 cs:- using LibVLCSharp.Shared;using System;using System.Collections.Generic;using System.Linq;using System.Security.Policy;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;namespace APngApp{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// Interaction logic for MainWindow.xaml<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>public partial class MainWindow : Window<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>private LibVLC _libvlc;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>public MainWindow()<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>InitializeComponent();<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>_libvlc=new LibVLC();<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>private void Window_Loaded(object sender, RoutedEventArgs e)<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label> <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>videoView.MediaPlayer = player; <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri("rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream")))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>videoView.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}}
复制代码 如果一切正常,将看到如下的画面,并且在VS实时可视化树中将看到 ForegroudWindow 和 MainWindow。
- 可以看到虽然我们仅仅创建了一个MainWindow,但是确实有两个窗体存在,VideoView控件为程序生成了一个ForegroudWindow。
- 当我们在VideoView内部编写一个button控件的时候,控件正确的显示出来了,如果我们将这个button移动到和vlc:VideoView并列的位置,按钮将不会显示出来,因为它被ForegroudWindow遮住了,这很诡异,也很有趣,这里就不列举并列写法的代码了。
- 官方(videolan)把这种情况总结为空域问题,即 Airspace。
- 不难看出来VideoView控件的这种设计有悖常理,但是据说这是由于LibVLC和vlc的局限性导致的,属于妥协式设计。但是大可放心使用,LibVLCSharp这套解决方案使用非常的广泛,而且截至目前(2023)官方issues仍非常活跃,并且版本也在不断更新中。官方也提供商业版本和付费的技术支持。
宽高比设置
宽高比设置是一个非常神奇的功能,它可以解决:
- 想让画面全屏显示却出现了间隙,这里的间隙是指画面没有完全覆盖窗体。
- 想要挤压或者拉伸画面却不知道如何实现。
- 在异形屏幕上面全屏显示画面,如:画面比例是16:9,想要在分辨率为5:5的屏幕上面全屏显示画面
- 其他宽高比问题,实际生产中,画面宽高比和屏幕宽高比都是不固定的,甚至可以说很随意,比如海康全景相机,其输出的画面本身就是宽度远高于高度,再比如同一个WPF程序需要在分辨率为1366768和25601440的屏幕分辨率下面全屏显示
- 这里提到的画面是指rtsp源本身的画面大小
通过如下代码和现象可以很直观的观察到宽高比的神奇之处。
全屏问题
环境:Windows11,屏幕分辨率为2560*1440,未设置缩放
- 新建一个WPF的窗体,引入VideoView控件,并在Window_ContentRendered 事件中初始化 MediaPlayer 以播放rtsp流。
- 为尽可能排除其他因素对本问题的影响,将对窗体和VideoView控件做如下初始化设置:
- 窗体的WindowStyle=None
- 窗体的ResizeMode=NoResize
- 窗体的AllowTransparency=true
- 设置窗体初始宽高为屏幕工作区域,即不包括任务栏部分,此时实际高度小于1440
- 设置video控件的 宽高为窗体的宽高
xaml代码:- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>
复制代码 cs:- using LibVLCSharp.Shared;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace RambleWPF{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// 视频控件3.xaml 的交互逻辑<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>public partial class 视频控件3 : Window<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>readonly LibVLC _libvlc;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>public 视频控件3()<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>InitializeComponent();<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>_libvlc = new LibVLC();<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>this.WindowStyle = WindowStyle.None;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>ResizeMode = ResizeMode.NoResize;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>AllowsTransparency = true;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//工作区域就是不包括任务栏的其他区域<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>double x = SystemParameters.WorkArea.Width;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//得到屏幕工作区域宽度<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>double y = SystemParameters.WorkArea.Height;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Width = x;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Height = y;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Top = 0;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Left = 0;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.Width = x;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.Height = y;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>private void Window_ContentRendered(object sender, EventArgs e)<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer = player;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}}
复制代码 此时启动程序,如果不出意外,将看到如下的存在“间隙”的画面:
可以看到虽然在初始化的时候我们显示指定了video控件的宽高等于窗体的宽高,但是由于rtsp视频源的画面宽高比和窗体的宽高比不一致,所以出现了“间隙”。要如何解决此问题呢?只需要在Window_ContentRendered中主动设置video.MediaPlayer的宽高比为video控件的宽高即可。
修改后的 Window_ContentRendered 是这样的:- private void Window_ContentRendered(object sender, EventArgs e){<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer = player;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>player.AspectRatio = video.Width + ":" + video.Height;}
复制代码 修改后的画面是这样的:
- 可以看到间隙已经没有了,画面按照预期的方式显示了。
拉伸问题
环境:Windows11,屏幕分辨率为2560*1440,未设置缩放
通过对全屏问题的分析,拉伸问题其实就很好理解了,只需要设置特定的宽高比即可实现,如下代码将对画面纵向和横向进行拉伸- /// /// 挤压和拉伸/// /// /// private void extrusion_Click(object sender, RoutedEventArgs e){<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer.AspectRatio = this.Width + ":" + 100;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//video.MediaPlayer.AspectRatio = 100 + ":" + video.Height;}
复制代码 响应鼠标点击事件
由于空域问题的存在,视频画面是无法响应鼠标点击事件的,不过有一个曲线救国的办法:
- 首先设置videoView控件的 isEnable 属性为false
- 然后在视频画面上面放一个遮罩层,遮罩层背景需要设置为透明,此时点击画面将可以获取到响应的事件
核心代码如下:
初始化VideoView:- private void Window_ContentRendered(object sender, EventArgs e){<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.IsEnabled = false;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer = player;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>player.AspectRatio = video.Width + ":" + video.Height; }
复制代码 遮罩层xaml:- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label> <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label> <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>
复制代码 其中,mask_MouseLeftButtonDown 和root_grid_MouseLeftButtonDown 事件可以正常响应。
而video_MouseLeftButtonDown 事件无法响应,因为空域的存在,此事件要么绑定在ForegroudWindow上面,要么可能就没有成功被委托。
播放其他类型
如下代码演示了播放M3U8和本地文件:- private void Window_ContentRendered(object sender, EventArgs e){<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.IsEnabled = false;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//rtsp 播放串<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//string url = "rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//m3u8播放串<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//string url = "http://1257120875.vod2.myqcloud.com/0ef121cdvodtransgzp1257120875/3055695e5285890780828799271/v.f230.m3u8";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//播放文件<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "C:\\Users\\cml\\Desktop\\temp\\流浪地球2.mp4";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer = player;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>player.AspectRatio = video.Width + ":" + video.Height;}
复制代码 多视频重叠
在一个窗体中播放两个视频,一个在后,全屏显示,一个在前,小窗播放。并且点击按钮可以切换画面位置。效果如下:
实现思路:
- 首先,其实只要在xaml中编排好VideoView控件的上下位置就可以实现重叠了 ,越靠上的控件会覆盖在靠下的控件上方。
- 切换功能的实现需要分别销毁前后两个VideoView的MediaPlayer.Media对象,并重新创建。
代码如下:
xaml:- <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>
复制代码 cs:- using LibVLCSharp.Shared;using System;using System.Collections.Generic;using System.Linq;using System.Security.Policy;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace RambleWPF{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// 视频控件2.xaml 的交互逻辑<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>/// <Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>public partial class 视频控件2 : Window<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>readonly LibVLC _libvlc;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>public 视频控件2()<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>InitializeComponent();<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>_libvlc = new LibVLC();<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>WindowStyle = WindowStyle.None;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>ResizeMode = ResizeMode.NoResize;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>AllowsTransparency = true;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//工作区域就是不包括任务栏的其他区域<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>double x = SystemParameters.WorkArea.Width;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>//得到屏幕工作区域宽度<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>double y = SystemParameters.WorkArea.Height;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Width = x;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Height = y;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Top = 0;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>win.Left = 0;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>private void Window_Loaded(object sender, RoutedEventArgs e)<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>Canvas.SetLeft(main_video, 100);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>Canvas.SetZIndex(main_video, 1);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>main_video.Width = 1366;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>main_video.Height = 768;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>Canvas.SetLeft(small_video, 150);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>Canvas.SetTop(small_video, 500);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>Canvas.SetZIndex(small_video, 2);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>small_video.Width = 300;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>small_video.Height = 168.75;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>private void Window_ContentRendered(object sender, EventArgs e)<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>this.Tag = main_video.Name;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>main_video.MediaPlayer = player;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>main_video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url2 = "rtsp://xxx:xxx@192.168.1.142:554/Streaming/Channels/1";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>LibVLCSharp.Shared.MediaPlayer player2 = new LibVLCSharp.Shared.MediaPlayer(_libvlc);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>small_video.MediaPlayer = player2;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url2)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>small_video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>private void switch_Click(object sender, RoutedEventArgs e)<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url = "rtsp://xxx:xxx@192.168.1.120:554/ch1/main/av_stream";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>string url2 = "rtsp://xxx:xxx@192.168.1.142:554/Streaming/Channels/1";<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>if (this.Tag as string != main_video.Name)<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>this.Tag = main_video.Name;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>main_video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url2)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>small_video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>else<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>this.Tag = small_video.Name;<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url2)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>main_video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>using (LibVLCSharp.Shared.Media media = new Media(_libvlc, new Uri(url)))<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>{<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>small_video.MediaPlayer.Play(media);<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label><Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}<Label Width="70" Height="70" Margin="5,0,5,0" Name="snapshot" MouseLeftButtonDown="snapshot_MouseLeftButtonDown" Cursor="Hand">
- <Label.Background>
- <ImageBrush ImageSource="/Images/small_video_hide.png" Stretch="Uniform"/>
- </Label.Background>
- </Label>}}
复制代码
- small_video显示在前,为小屏;main_video显示在后,全屏显示
画中画
画中画本质上还是视频的重叠,可以参考视频重叠的实现思路实现。
引用
技术交流QQ群:1158377441 欢迎关注我的微信公众号,后续博文将在公众号首发:
来源:https://www.cnblogs.com/Naylor/archive/2023/02/14/17118993.html
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作! |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|