1

There is my code. I see the video in the top right corner, where control itself is located, but the main grid background is empty. It's supposed to take video through VisualBrush, right? I've googled few samples and they all use the same trick, but it doesn't work...

I've also tried to put some controls on top of the control, but nothing shows through, because I assume it's using WinForms control inside, which is top-most.

So how do I get this video as the background?

<Grid>
    <vlc:VlcControl  x:Name="myVlcControl" Width="100" Height="100" HorizontalAlignment="Right" VerticalAlignment="Top" />
    <Grid>
    <Grid.Background>
        <VisualBrush Stretch="Uniform">
            <VisualBrush.Visual>
                <Image Source="{Binding VideoSource, ElementName=myVlcControl}" />
            </VisualBrush.Visual>
        </VisualBrush >
    </Grid.Background>
</Grid>
  • The tutorials you've seen will be for the old version of Vlc.DotNet. A newer version was released around the start of 2015 which uses a WPF HwndHost to display a WinForms player. Just did some poking about and I don't think that you can use a VisualBrush with a HwndHost. – goobering Jun 02 '15 at 12:24
  • Well, this explains why it's not working. Any alternatives? I need to show rtsp stream... – Shaine Eugene Mednikov Jun 02 '15 at 18:43
  • If you only need to display your feed then you could try a MediaElement. Pretty sure it supports RTSP and VisualBrushes. – goobering Jun 02 '15 at 18:50
  • Love it when I find out new things on SO. I'm just about to go and try this out, but it looks promising for your issue: http://www.jonathanantoine.com/2011/09/24/wpf-4-5-%E2%80%93-part-8-no-more-airspace-problems-integrating-wpf-with-win32 . – goobering Jun 02 '15 at 22:46
  • Scratch that: http://stackoverflow.com/questions/9535167/has-airspace-support-definitely-been-dropped-in-wpf-4-5 . – goobering Jun 02 '15 at 22:53
  • I've tried the standard MediaElement, but it doesn't support rtsp – Shaine Eugene Mednikov Jun 08 '15 at 10:17
  • Also tried WPFMediaKit, but I wasn't able to integrate it at all – Shaine Eugene Mednikov Jun 08 '15 at 10:19

2 Answers2

0

MediaElement supports RTSP just fine, but it may not support the encoding/container you're trying to work with. The following produces a working streaming MediaElement, and uses a VisualBrush to paint the background of a Grid with the MediaElement:

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>

    <MediaElement x:Name="MyPlayer"
                Width="640"
                Height="480"
                LoadedBehavior="Play"
                Source="rtsp://granton.ucs.ed.ac.uk/domsdemo/v2003-1.wmv" />

    <Grid Grid.Row="1"
        Width="320"
        Height="240">
        <Grid.Background>
            <VisualBrush Stretch="Uniform" Visual="{Binding ElementName=MyPlayer}" />
        </Grid.Background>
    </Grid>
</Grid>
goobering
  • 1,547
  • 2
  • 10
  • 24
0

@Kolorowezworki made Airhack control to workaround this issue.

Example:

   <airhack:AirControl DataContext="{Binding}">
           <airhack:AirControl.Front>
                 <Image Source="{Binding VideoSource, ElementName=myVlcControl}" />
           </airhack:AirControl.Front>
           <airhack:AirControl.Back>
                 <vlc:VlcControl  x:Name="myVlcControl" Width="100" Height="100" HorizontalAlignment="Right" VerticalAlignment="Top" />
           </airhack:AirControl.Back>
   </airhack:AirControl>

NOTE: By default AirControl does't support DataContext Binding, to solve this issue fork or copy repository and implement DataContext support by passing it 'airhack' window.

Example:

 public AirControl()
 {
       InitializeComponent();
       alpha = new Alpha(this);
       alpha.DataContext = DataContext;
       DataContextChanged += (sender, args) => alpha.DataContext = DataContext;
 }
Piwnik
  • 181
  • 1
  • 5