1

I'm writing a WPF desktop application, with some video playback functions. I decided to use LibVLCSharp.WPF to complete the playback task.

Xaml code:

<UserControl ...
             xmlns:vlc="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
             ... >
    <vlc:VideoView VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
        <Canvas VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MouseEnter="Canvas_MouseEnter">
        </Canvas>
    </vlc:VideoView>
</UserControl>

It works fine with playing video, but when I tried to put some hidden controls inside Canvas (or any other type of Panel control) and change their visiblity with MouseEnter event, nothing happens.

While debugging, I found out that MouseEnter event can only fire when Canvas has at least one visible control as its child, and mouse pointer entered that visible control.

I have read the articles about "airspace issue". It seems nothing to do with me since I just want to draw a control layer exactly inside playback area.

Is there any way that I can put an auto show panel on VLC player, which only shows when mouse "hovered" over playback area?

  • seems related to https://code.videolan.org/videolan/LibVLCSharp/issues/267#note_48214 . Did you try to set a Background color? – cube45 Dec 06 '19 at 11:15
  • The thing that you need to understand is that putting controls inside of the VideoView is really a hack. These controls are detached and placed in a window over the VideoView, which is why the event don't bubble – cube45 Dec 06 '19 at 11:20
  • @cube45 I changed my panel's background to "#01000000", and it worked. Thanks. – Unmeltable Ice Dec 09 '19 at 02:30

1 Answers1

3

Problem solved with hint from @cube45 . Thank you.

I changed Background of Canvas to something that "not so transparent".

Xaml code:

<Canvas Background="#01000000" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MouseEnter="Canvas_MouseEnter">
</Canvas>

And mouse events worked. Tricky, but useful.

  • Transparent background is default value, and that was my problem. I guess LibVLCSharp library will treat completely transparent items as "something not exist" @cube45 – Unmeltable Ice Dec 09 '19 at 11:19
  • I was asking that because there seems to be a difference between left by default, and set to Transparent explicitely, as per this thread : https://stackoverflow.com/questions/7991314/mouse-event-on-transparent-background – cube45 Dec 09 '19 at 15:51
  • @cube45 I tried it today and... it won't work. I set backgroud to transparent manually, then no mouse events can fire anymore. – Unmeltable Ice Dec 10 '19 at 12:14