This kind of question is asked many times.
but for some reason its not working as expected!
i'm using vlc in a Panel(Control) then placed a label on top of vlc control.
i want label's background to be transparent. i used below code
label1.Parent = vlcControl1;
label1.backColor = Color.Transparent;
The issue here is that label displays until vlc is not playing any media.
as soon as i play a media file, label gets hidden.
i also tried
label1.bringToFront();
label1.Visible=true;
if i stop vlc from playing a video file vlcControl1.Stop(); label will then be visible.
-
Overlaying video may well take an extra window.TaW– TaW2016年11月20日 17:16:58 +00:00Commented Nov 20, 2016 at 17:16
-
@TaW any workaround to overlay text on video?Prakash– Prakash2016年11月21日 02:37:15 +00:00Commented Nov 21, 2016 at 2:37
-
There are many ways of using a VLC control in a C# project. What are you using?Josep B.– Josep B.2016年11月21日 13:42:58 +00:00Commented Nov 21, 2016 at 13:42
-
@JosepB, like i mentioned in Question. i'm using VlcDotNetPrakash– Prakash2016年11月23日 06:29:10 +00:00Commented Nov 23, 2016 at 6:29
4 Answers 4
The Windows Forms version has the airspace issue, and I don't know available workarounds for solving it.
For the WPF version, this is a known problem of the last version of VlcDotNet: Wpf VlcControl seems to ignore ZIndex and VlcControl is always on the top of my window It happens since the WPF VLC control is a HwndHost displaying the Windows Forms control.
The known alternatives should be, using WPF and:
- Use the old version of VlcDotNet (version 1.2.0.0 hasn't the airspace issue)
- Use an alternative control with a pure WPF implementation, for example Meta.Vlc
- Implement a workaround for the airspace issue, for example AirspacePopup
Comments
Here is the current state of the art, in 2019:
As of Vlc.DotNet 3.0, the WPF control doesn't have the airspace issue. However, rendering is done on the CPU, which kills perf (aka, you shouldn't be using it) ( https://github.com/ZeBobo5/Vlc.DotNet/issues/296 )
With LibVLCSharp, another approach was taken, that implements an airspace hack.
Sadly, it's all tradeoffs...
Comments
I had this problem to set subtitle handly and I change my strategy to don't use any label from my own or anything else. actually Libvlc C# (libvlcSharp) has an option to do this with Marquee. this is my code:
_mediaPlayer.SetMarqueeInt(VideoMarqueeOption.Enable, 1); //enable marquee option
_mediaPlayer.SetMarqueeInt(VideoMarqueeOption.Size, 32); //set the font size
_mediaPlayer.SetMarqueeInt(VideoMarqueeOption.Position, 8); //set the position of text
_mediaPlayer.SetMarqueeString(VideoMarqueeOption.Text, "my text"); //to set subtitle or any other text
position have options like this and also you can set position by _mp.SetMarqueeInt(VideoMarqueeOption.X, 50); and _mp.SetMarqueeString(VideoMarqueeOption.Y, 50);
1 Comment
or use vlc on another form.. behind. then open form2, with controls on it. Place the controls on the second form, with 'transparent backgrounds' they will float on the video. Sometimes need to fix anti-alias