如何播放MemoryStrem Video C#? [英] How To Play MemoryStrem Video C# ?

查看:78
本文介绍了如何播放MemoryStrem Video C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们



我有大问题



如何在WinForms中从MemoryStream播放视频使用C#



非常感谢

解决方案

如果您可以放弃要求从MemoryStream播放并且很开心要从文件中播放,您可以在表单ElementHost中使用WPF MediaElement:

 ElementHost host =  new  ElementHost (); 
MediaElementControl mediaElement = new MediaElementControl();
host.Child = mediaElement;
this .Controls.Add(host);
mediaElement.mediaPlayer.Source = new Uri( @ C:\temp\delta.mpg);
mediaElement.mediaPlayer.LoadedBehavior = System.Windows.Controls.MediaState.Manual;
mediaElement.mediaPlayer.Play();



MediaElementControl.xaml

 <   usercontrol     x:class   =  WindowsFormsApplication2.MediaElementControl    xmlns:x   = #未知 >  
xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml
xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006
xmlns:d =http://schemas.microsoft.com/expression/blend/2008>
< mediaelement < span class =code-attribute> x:name = mediaPlayer / >
< / usercontrol >


Hi ,Guys

I Have Big Problem

How Can Play Video From MemoryStream In WinForms Using C#

Thanks Alot

解决方案

If you can drop the requirement to play from MemoryStream and are happy to play it from file, you could use WPF MediaElement inside forms ElementHost:

ElementHost host = new ElementHost();
MediaElementControl mediaElement = new MediaElementControl();
host.Child = mediaElement;
this.Controls.Add(host);
mediaElement.mediaPlayer.Source = new Uri(@"c:\temp\delta.mpg");
mediaElement.mediaPlayer.LoadedBehavior = System.Windows.Controls.MediaState.Manual;
mediaElement.mediaPlayer.Play();


MediaElementControl.xaml

<usercontrol x:class="WindowsFormsApplication2.MediaElementControl" xmlns:x="#unknown">
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
<mediaelement x:name="mediaPlayer" />
</usercontrol>


这篇关于如何播放MemoryStrem Video C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆