How to play mp3 stream using the MediaElement class from WPF? - wpf

I wondering if the MediaElement component (from WPF) is capable of playing and buffering mp3 streams.
I need play mp3 memory stream(not mp3 file) using MediaElement of WPF, if possible would you please tell me how to do it.
thanks a lot

Sadly this is functionality has not been implemented in WPF. There is a workaround quoting from a codeproject
"Since MediaElement control with
Source property from WPF cannot
receive byte[] or Stream, we can
manipulate it using ASP.NET as a video
stream."
Building a Personal Diary with WPF
Alternatively you could embed a plugin such as the VideoLan DotNet for WinForm & WPF which can stream files, and has very wide codec support. The downside to this is VideoLAN needs to be installed locally on the machine.
On another note there is a feature request to implement this in WPF. If you feel obliged, then vote;
WPF Feature Suggestions - Add stream capability to MediaElement

MemoryStream s;
...
MediaElement m = new MediaElement();
m.SetSource(s);

Related

How to stream videos in WPF?

I want to stream video in a WPF application. There are two potential ways:
Embed VLC. Problem: I know how to embed VLC in a WinForm application but not in a WPF one.
Use MediaElement. Problem: I know how to play a wmv file, but I don't know how to play a stream.
So what can I do to play video streams in WPF?
It's very easy task. You can find out VlcDotnet. it's open source and using the VLC libraries. This is the Github link. It is fit with WPF.
Source File

How to use a windows forms embedded resource as the Source for a WPF mediaelement?

I am hosting a MediaElement in a WinForms application, which I would like to play both images and video through. My images and video are set as embedded resources to the application.
The MediaElement.Source property only accepts a URI.
Any ideas on how to get the MediaElement to play the embedded resourece files without writing them to disk?
Thanks.
MediaElement cannot play from embedded resources files. It would be possible by writing your own DirectShow source filter, but that might be a lot of work for little benefit.

MediaElement Support in WPF

I am evaluating WPF and Silverlight for a Project. I find WPF to be most suited for our purpose since we require performance, graphics support, Office compatibility and the ability to support ActiveX controls. It is also a Desktop application. However there is one area where i find Silverlight to be superior - Media support. I would like to have the WPF mediaelement control to support MPEG4 (H.264) codec.
Can anyone please suggest if this is feasible somehow and if support for the same is in the roadmap of WPF?
The WPF MediaElement uses DirectShow under the convers (well it uses WMP, but WMP uses DShow), so as long as you have an h264 codec installed (Windows 7 comes with them), your MediaElement should be able to play h264 video.
The WPF MediaElement requires the Windows Media Player 10 or above (this can be some deployment problem, so please read the Redistributing Windows Media Player Software) and uses DirectShow filter (codecs) installed on the user's computer. A general rule is if you can play your file in WMP you can play it in MediaElement.
For Silverlight you can found here the Supported Media Formats, Protocols, and Log Fields.
I have some experience with WPF media element but it has some performance hit. so if u have to show image and video you can use D3DImage of WPF in SP1 of .NET 3.5 that is new control of WPF for DirectX interaction and it has better performance over media element. more on D3DImage

Video and Audio Editing components

I need to write a video and audio capability in a WPF application. It need to do video and voice capture with basic editing etc.
Does anyone know of any components that could get me going.
Directshow will be required for audio/video capture from a DV camera unless you are running Windows 7. Then you can use Media Foundation. In both cases, you will need .NET interface libraries, which are already completed (Directshow here and Media Foundation here). I'm not sure if the Media Foundation interface library has support for the new capture functionality though.
I would check out the SpeechRecognizer class, which is new in .NET 3.0. In fact the entire System.Speech namespace is a good starting place for voice capture.
As for video, MediaElement is a full-blown FrameworkElement designed to play audio and video, which can be embedded into your WPF applications.

How to stream Webcam in WPF?

Can I stream a live video in WPF application from my web cam? If yes, then How?
You will have to use DirectX Capture or something (is not in WPF right know, so use DirectX API's directly).
Look at: WPF Media Kit. It can grab the Vista Windows desktop manager DirectX Direct3D shared Surface, and use it as a visual brush in WPF. He does some nice things with it. Look at his blog where he explains it.
I hope this helps you on your way...
UPDATE 2009-11-06:
The VideoRenderElement Codeplex project has an example on how to stream webcam content.
This project looks like it would fit your requirment perfectly.
UPDATE 2013-02-18:
Alternatively one can use the Expression Encoder SDK. For an example you can look at the WPF-Webcam-Control article on CodeProject

Resources