使用的MediaElement从流播放视频 [英] Using MediaElement to play video from Stream
问题描述
是否有可能使用WPF的MediaElement播放从的System.IO.Stream对象的视频流?流对象正在从存储媒体文件的WCF服务检索。
Is it possible to use the WPF MediaElement to play streaming video from a System.IO.Stream object? The Stream object is being retrieved from a WCF service that stores the media files.
推荐答案
如果你可以让WCF通过 HTTP-URL(GET)提供的媒体对象
你再可以只分配一个URL到 MediaElement.Source
属性 - 请参阅<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source.aspx\">http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source.aspx.
IF you can make the WCF deliver the Media Object via a http-URL (GET)
then you can just assign that URL to the MediaElement.Source
property - see http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source.aspx.
对于在这样的URL是不可用/可能的情况:
For cases where such URL is not available/possible:
指定的Stream目前不可能的 - 虽然有一些黑客要做到这一点,对于一个基于DirectShow的例子中看到的<一个href=\"http://social.msdn.microsoft.com/forums/en-US/wpf/thread/6191ef1a-0010-4294-a5b4-451bbadca33a/\">http://social.msdn.microsoft.com/forums/en-US/wpf/thread/6191ef1a-0010-4294-a5b4-451bbadca33a/和<一个href=\"http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/15/WPF-Hackery-Part-I.aspx\">http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/15/WPF-Hackery-Part-I.aspx
Assigning a Stream is currently not possible - although there are some hacks to make that happen, for a DirectShow-based example see http://social.msdn.microsoft.com/forums/en-US/wpf/thread/6191ef1a-0010-4294-a5b4-451bbadca33a/ and http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/15/WPF-Hackery-Part-I.aspx .
另一种选择是,以某种方式举办 Silverlight中的MediaElement
和使用,可以采取流的SetSource
方法发挥它......看到<一个href=\"http://silverlightviewport.$c$cplex.com/SourceControl/list/changesets\">http://silverlightviewport.$c$cplex.com/SourceControl/list/changesets和<一个href=\"http://msdn.microsoft.com/en-us/library/cc190669%28v=vs.95%29.aspx\">http://msdn.microsoft.com/en-us/library/cc190669%28v=vs.95%29.aspx
Another option would be to somehow host the Silverlight MediaElement
and use the SetSource
method which can take a stream and play it... see http://silverlightviewport.codeplex.com/SourceControl/list/changesets and http://msdn.microsoft.com/en-us/library/cc190669%28v=vs.95%29.aspx
这篇关于使用的MediaElement从流播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!