Play video from UDP / RTSP with MediaElement?

Can I play videos streamed from UDP / RTSP using the WPF MediaElement control? During my testing, I tried to pass a URI containing a UDP stream to the MediaElement player, but when I launch the application, the media player is empty as if there is no media source. Here's 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 I'm missing here? I tested this setup using a video that is stored on my file system and it plays without issue - it's just streaming that doesn't want to work.

If this is not possible with a MediaElement, I am open to suggestions for controls that I can use instead. However, I need a control that is pure WPF and independent of WinForms interop. Any suggestions are greatly appreciated.

UPDATE: After creating the "MediaFailed" event handler, I was able to get this error: "Media upload failed" with internal System.Runtime.InteropServices.COMException with HResult 0xC00D0FEA. I referred to this: MediaPlayer cannot play filenames without extension and tried some registry changes, but they don't seem to fix the problem. Again, any suggestions are appreciated. I will keep updating this thread as I get more information.

+3


source to share


2 answers


After a bit of research, it seems that what I am trying to do may not be possible. The WPF MediaElement (and Windows Media Player) seems to support playing video over a network, but not from a stream. See the next section 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 looking at a WPF control that will play video from a stream, but I couldn't find anything.

+2


source


See FFME , which is almost a replacement for FFmpeg-based MediaElement.



+1


source







All Articles