chelsea chelsea - 10 months ago 193
C# Question

Play video from UDP/RTSP using MediaElement?

Is it possible to play videos streamed from UDP/RTSP using WPF's MediaElement control? During my testing, I have attempted to pass a URI containing a UDP stream to the MediaElement player, but when I launch my application, the media player is blank as though there is no media source. Here is my sample code:


public partial class MainWindow: Window
public MainWindow()

VideoMediaElement.Source = new Uri("udp:\\\\@");


<Window x:Class="MyApplication.MainWindow"
Title="MainWindow" Height="300" Width="300">
<MediaElement Margin="5,5,5,5" Grid.Row="1" x:Name="VideoMediaElement" LoadedBehavior="Manual" />

Is there something obvious that I'm missing here? I have tested this setup using a video that is stored on my file system, and it plays with no problems - it's just the streaming that doesn't want to work.

If this is not possible using MediaElement, I am open to suggestions for controls that I can use instead. However, I need a control that is purely WPF and does not rely on any WinForms interop. Any suggestions are appreciated.

UPDATE: After creating a handler for the "MediaFailed" event, I was able to receive this error: "Media file download failed" with an inner exception of System.Runtime.InteropServices.COMException with HResult 0xC00D0FEA. I referenced this: MediaPlayer cannot play file names without an extension and attempted to make some changes to the registry, but they don't seem to be fixing the problem. Again, any suggestions are appreciated. I'll continue to update this thread as I get more information.

Answer Source

After A LOT of research, it seems that what I am attempting to do may not be possible. The WPF MediaElement control (and Windows Media Player) appear to support playing videos over a network, but not from a stream. See the following thread on MSDN:

I'm still on the lookout for a WPF control that will play video from a stream, but I haven't found anything.