Play video from UDP/RTSP using MediaElement?

4

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:

MainWindow.xaml.cs:

public partial class MainWindow: Window 
{
    public MainWindow() 
    {
        InitializeComponent();

        VideoMediaElement.Source = new Uri("udp:\\\\@12.3.4.567:890");
        VideoMediaElement.Play();
    }
}

MainWindow.xaml:

<Window x:Class="MyApplication.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="300" Width="300">
<Grid>
    <MediaElement Margin="5,5,5,5" Grid.Row="1" x:Name="VideoMediaElement" LoadedBehavior="Manual" />
</Grid>

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.

c#
wpf
media-player
asked on Stack Overflow Jul 14, 2015 by chelsea • edited May 23, 2017 by Community

2 Answers

4

See FFME, an almost drop-in replacement for MediaElement, based on FFmpeg.

answered on Stack Overflow Aug 22, 2016 by superware
2

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: https://social.msdn.microsoft.com/Forums/vstudio/en-US/e90b7e73-62b2-40b2-a725-4b60e02d65a1/play-video-stream-in-wpf?forum=wpf

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

answered on Stack Overflow Aug 3, 2015 by chelsea

User contributions licensed under CC BY-SA 3.0