WPF播放器
最近由于工作需要,需要做一个播放软件,在网上参考了很多例子,园子里有很多代码。其中最多的就是wpf自带的MediaElement控件,或者VLC视频播放器。
先附我自己查询资料的链接:
MediaEmelent控件例子
http://www.cnblogs.com/gnielee/archive/2010/05/06/wpf4-media-player-mediaelement.html
http://blog.zhigui.org/2011/04/wpf-simple-player/
VLC
http://www.cnblogs.com/Gavin001/archive/2013/05/01/3053465.html
由于我电脑可能是Ghost系统 或者由于被优化了。我发现我的MediaElement无法播放任何视频。通过控制面板关闭媒体中心之后,再也打不开了。真是坑!!!
只能放弃自带控件,查到有一个VLC的NET版。so。。。
附vlc.dotnet的github链接
https://github.com/ZeBobo5/Vlc.DotNet
首先,自己在nuget里面下载所需要的扩展:
完成之后 就看示例代码咯,github里面是有example的
<Window x:Class="Vlc.DotNet.Wpf.Samples.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Vlc.DotNet.Wpf.Samples"
xmlns:wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="" Width="">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> <wpf:VlcControl Grid.Row="" x:Name="myControl"/> <Button Grid.Row="" Click="OnPlayButtonClick">Play</Button>
<Button Grid.Row="" Click="OnForwardButtonClick" x:Name="Forward">Forward</Button>
<Button Grid.Row="" Click="GetLength_Click" x:Name="GetLength">Get Length</Button>
<Button Grid.Row="" Click="GetCurrentTime_Click" x:Name="GetCurrentTime">Get Current Time</Button>
<Button Grid.Row="" Click="SetCurrentTime_Click" x:Name="SetCurrentTime">Set Current Time to 5s</Button>
</Grid>
</Window>
首先加上 xmlns:wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
然后加上 <wpf:VlcControl Grid.Row="0" x:Name="myControl"/>
using System;
using System.IO;
using System.Reflection;
using System.Windows; namespace Vlc.DotNet.Wpf.Samples
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
myControl.MediaPlayer.VlcLibDirectoryNeeded += OnVlcControlNeedsLibDirectory;
} private void OnVlcControlNeedsLibDirectory(object sender, Forms.VlcLibDirectoryNeededEventArgs e)
{
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
if (currentDirectory == null)
return;
if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
//vlc的dll路径,自己下载vlc播放器里面的libvlc.dll libvlccore.dll以及plugins文件夹
e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"..\..\..\lib\x86\"));
else
e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"..\..\..\lib\x64\"));
} private void OnPlayButtonClick(object sender, RoutedEventArgs e)
{
myControl.MediaPlayer.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));
//myControl.MediaPlayer.Play(new FileInfo(@"..\..\..\Vlc.DotNet\Samples\Videos\BBB trailer.mov"));
} private void OnForwardButtonClick(object sender, RoutedEventArgs e)
{
myControl.MediaPlayer.Rate = ;
} private void GetLength_Click(object sender, RoutedEventArgs e)
{
GetLength.Content = myControl.MediaPlayer.Length + " ms";
} private void GetCurrentTime_Click(object sender, RoutedEventArgs e)
{
GetCurrentTime.Content = myControl.MediaPlayer.Time + " ms";
} private void SetCurrentTime_Click(object sender, RoutedEventArgs e)
{
myControl.MediaPlayer.Time = ;
SetCurrentTime.Content = myControl.MediaPlayer.Time + " ms";
}
}
}
代码地址为:https://github.com/ZeBobo5/Vlc.DotNet/blob/master/src/Samples/Vlc.DotNet.Wpf.Samples/
WPF播放器的更多相关文章
- 基于<MediaElement>的WPF视频播放器(可拖拽进度条播放)【1】
一.前言 前两天上峰要求做一个软件使用向导,使用WPF制作.这不,这两天从一张白纸开始学起,做一个播放演示视频的使用向导.以下是粗设计的原型代码: 二.效果图 三.代码 前台代码: < ...
- WPF技术触屏上的应用系列(四): 3D效果图片播放器(图片立体轮放、图片立体轮播、图片倒影立体滚动)效果实现
原文:WPF技术触屏上的应用系列(四): 3D效果图片播放器(图片立体轮放.图片立体轮播.图片倒影立体滚动)效果实现 去年某客户单位要做个大屏触屏应用,要对档案资源进行展示之用.客户端是Window7 ...
- 将WPF版的弹幕播放器给优化了一下
年前较闲的时候研究了一下WPF的性能优化,练手的时将之前写的弹幕播放器给重新写了一下.年前的时间不大够,没有写完,这两天接着弄了一下,基本上弄得差不多了. 主要重写了底层的渲染算法,优化后效果还是非常 ...
- 用WPF写了一个弹幕播放器
看弹幕视频的时候,如果不发弹幕,一个本地的弹幕播放器往往能带来更好的体验.目前已经有一些实现了,最初用过一个MukioPlayer, 后来又用过一个用C++写的BiliLocal,这个程序能自动下载弹 ...
- 简易音乐播放器主界面设计 - .NET CORE(C#) WPF开发
微信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏. 简易音乐播放器主界面设计 - .NET CORE(C#) WPF开发 阅读导航 本文背景 代码 ...
- 使用vlc进行二次开发做自己的播放器
可参考: 使用vlc播放器做rtsp服务器 使用vlc播放器播放rtsp视频 web网页中使用vlc插件播放相机rtsp流视频 使用 https://github.com/ZeBobo5/Vlc.Do ...
- WPF播放视频
在现在的项目中需要使用到播放视频的功能,本来打算使用VLC来做的.后来发现WPF 4.0之后新增了MediaElement类,可以实现视频播放. <Grid> <Grid.RowDe ...
- AR播放器
一.项目需求 AR播放器:将一系列带透明通道的图片以一定的帧率连续显示,叠加载摄像头采集的画面之上,并播放声音. 此为最初级的AR技术,因为画面是事先渲染好的,固定不变的,所以实际上并不能实现“互动” ...
- 基于VLC的播放器开发
VLC的C++封装 因为工作需要,研究了一段时间的播放器开发,如果从头开始做,可以学习下FFmpeg(http://www.ffmpeg.org/),很多播放器都是基于FFmpeg开发的,但是这样工作 ...
随机推荐
- C++项目作业 学生管理系统
/*Student.h*/#pragma once #include<string.h> using namespace std; #include<string> class ...
- JavaScript学习笔记之BOM对象
目录 1.Window 2.Window Screen 3.Window Location 4.Window History 5.Window Navigator 浏览器对象模型(Browser Ob ...
- Arduino 串口通讯参考笔记 - Serial 类库及相关函数介绍
声明: 本ID发布的所有文章及随笔均为原创,可随意转载,单转载文章必须注明作者 aiyauto 及包含原文出处地址 http://www.cnblogs.com/aiyauto/p/7071712.h ...
- textarea 提交到数据库的内容,输出到 html 中显示正常的格式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 像 IDE 一样使用 vim
本文转载自:https://github.com/yangyangwithgnu/use_vim_as_ide ##[目录] 0 vim 必知会........0.1 .vimrc 文件....... ...
- Wizard's Tour
F. Wizard's Tour time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- nyoj_17_单调递增最长子序列_201403121516
单调递增最长子序列 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4 输入 ...
- POJ 3653 & ZOJ 2935 & HDU 2722 Here We Go(relians) Again(最短路dijstra)
题目链接: PKU:http://poj.org/problem? id=3653 ZJU:problemId=1934" target="_blank">http ...
- .NET几大热点问题(.NET人员必读)
下面收集了关于.NET几大热点问题及简要答案,防止我们回答问题不专业的尴尬.同一时候还将一些.NET资源的相关网址罗列一二. 一.什么是.Net?它主要包含什么? .Net是为简化在第三代因特网的高 ...
- MFC小程序003------MFC使用WebBrowser组件,在对话框中创建滚动视图,动态创建一个静态文本控件并设置鼠标单击的消息响应
MFC小程序截图: 一.在MFC中简单使用WebBrowser的ActiveX插件的方法: 见博文: http://blog.csdn.net/supermanking/article/detail ...