在 WPF 中播放流媒体视频 [英] Playing streaming video in WPF

查看:156
本文介绍了在 WPF 中播放流媒体视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个流媒体文件的 WCF 服务.我现在正在编写一个使用此服务的 WPF 应用程序,并且刚刚发现 MediaElement 不接受 Stream 对象作为源属性的输入参数.

I've written a WCF service that streams media files. I'm now writing a WPF application that consumes this service and have only just found out that the MediaElement does not accept Stream objects as input parameters for the source property.

过去两天我一直在谷歌上无休止地搜索,并研究了几种替代方案,包括 WPF 中的 Silverlight 视口、VLC ActiveX 控件、VideoRendererElement 和 WPFMediaKit.不幸的是,我一直受到缺乏文档和/或示例的阻碍,到目前为止还没有真正取得任何进展.事实上,这是我第一次使用 WPF 也无济于事.

I've been Googling endlessly for the past two days and have looked at several alternatives including the Silverlight Viewports inside WPF, VLC ActiveX controls, VideoRendererElement and WPFMediaKit. Unfortunately I've been hampered by lack of documentation and/or examples and haven't really made any progress so far. The fact that this is the very first time I'm using WPF doesn't help either.

简而言之,我正在寻找的是随附在 WPF 中演示流式传输的文档或示例的内容,并且如果可能的话,实现起来也很简单.解决方案不一定是完美的;我所需要的只是有效的东西.

To put it simply, what I'm looking for is something that comes with documentation or examples demonstrating streaming in WPF and, if possible, is also straightforward to implement. The solution doesn't have to be perfect; all I need is something that works.

推荐答案

您可以主持一个 HttpListener 在 WPF 应用程序中,并通过由 HttpListenerMediaElement.Source .

You could host a HttpListener inside your WPF app and supply the stream which you receive from your WCF service through an URL which is served by HttpListener to MediaElement.Source .

其他选项(尽管您似乎已经排除了它们):

Other options (though you seem to have ruled them out):

不确定这是否适合您,但有用于多媒体的商业库,包括从 WPF 中的流播放视频:

Not sure if this is an option for you, but there are commercial libraries for multimedia including video playback from streams in WPF:

这篇关于在 WPF 中播放流媒体视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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