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.
See FFME, an almost drop-in replacement for MediaElement, based on FFmpeg.
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.
User contributions licensed under CC BY-SA 3.0