1

I'm trying to use Microsoft Expression Encoder 4.0 in my application. The first problem I'm facing is that I need to catch the streamed video from the url in c#, but in the sample of the library, they used WPF and it only has this code to show the streaming video

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Show Broadcast" Height="350" Width="525">
    <Grid>
        <MediaElement Name="VideoControl" Source="http://localhost:8080" />
    </Grid>
</Window>

How would I convert this code to c# code so I can show the streaming video in a pictureBox?

Jeromy French
  • 11,812
  • 19
  • 76
  • 129
Murhaf Sousli
  • 12,622
  • 20
  • 119
  • 185
  • 1
    Is your keyboard missing the ',' key? – Folkert van Heusden Apr 11 '12 at 10:53
  • @FolkertvanHeusden very funny – Murhaf Sousli Apr 11 '12 at 10:59
  • catching an incoming video stream, and responding to the protocol prompts, may be more complex than you seem to suggest, and trying to display it in a PictureBox (winforms?) may be ambitious.... what is you actually need to do here? can you not embed a media player control? – Marc Gravell Apr 11 '12 at 11:02
  • @MarcGravell yes, its a Winform forgot to tag this,and no i can't embed a media player, as i posted the code was just this in the wpf sample, check this out http://www.codeproject.com/Articles/202464/How-to-use-a-WebCam-in-C-with-the-NET-Framework-4 that piece of code catches the streaming video – Murhaf Sousli Apr 11 '12 at 11:13
  • 2
    @Mur no it doesn't - it asks `MediaElement` to handle all that; it does **nothing** itself. The winforms equivalent is probably media player (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd562851(v=vs.85).aspx) - so... **why** can't you embed a media player here? you do, after all, wish to play media... – Marc Gravell Apr 11 '12 at 11:15
  • @MarcGravell i will try it and tell you the result. – Murhaf Sousli Apr 11 '12 at 11:30
  • 2
    YOu better do, because the stream is RTP based so you ahve to implement RTP and RTSP protocol handlers and do the decoding. YOu can use media playoer or DirectShow to set up a render graph that goes onto any window (that is windows level window - easy to get a handle to any user control in winforms as a handle). – TomTom Apr 11 '12 at 11:34

1 Answers1

0

In winforms? The most similar equivalent would be to embed a media player control. In the sample in the question, the WPF engine is offloading all the work of decoding to MediaElement - there is a lot involved in most video streaming protocols, and similar effort in handing the data to the UI subsystems. You really don't want to do that yourself.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900