VideoView does not support AllowsTransparency Window in Virtual Machine (VMWare)
In order to test whether the software can run on more computer operating systems (such as Win7, Win8, Win10), I used Virtual Machine (VMWare) to test the software. But I found that when the Window's property AllowsTransparency is set to True, VLC Control will not be able to display anything while playing the video.
The specific performance is that the video is not displayed, but the sound can be played.
You can see this video.
Full Test C# code .NET 6.0 With Visual studio 2022 (With LibVLCSharp.WPF 3.6.6)
VMware 16 + Windows 10
Change const string filePath = @"C:\TestFiles\001.mp4";
to your path.
MainWindow.xaml
<Window x:Class="WPFAllowsTransparencyTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button x:Name="btnWithoutAllowsTransparency" Content="Show Without AllowTransparent" Margin="254,112,223,261" Click="btnWithoutAllowsTransparency_Click" />
<Button x:Name="btnAllowsTransparency" Content="Show AllowTransparent" Margin="254,217,223,156" Click="btnAllowsTransparency_Click" />
</Grid>
</Window>
MainWindow.xaml.cs
using System.Windows;
using System.Windows.Media;
namespace WPFAllowsTransparencyTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnWithoutAllowsTransparency_Click(object sender, RoutedEventArgs e)
{
var window = new TestWindow();
window.ShowDialog();
}
private void btnAllowsTransparency_Click(object sender, RoutedEventArgs e)
{
var window = new TestWindow()
{
Background = Brushes.Transparent,
AllowsTransparency = true,
WindowStyle = WindowStyle.None,
};
window.ShowDialog();
}
}
}
TestWindow.xaml
<Window x:Class="WPFAllowsTransparencyTest.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:VLC="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="TestWindow" Height="400" Width="600" ContentRendered="Window_ContentRendered">
<Grid>
<VLC:VideoView x:Name="player" x:FieldModifier="private">
</VLC:VideoView>
</Grid>
</Window>
TestWindow.xaml.cs
using LibVLCSharp.Shared;
using System.Windows;
namespace WPFAllowsTransparencyTest
{
public partial class TestWindow : Window
{
public TestWindow()
{
InitializeComponent();
}
private void Window_ContentRendered(object sender, System.EventArgs e)
{
const string filePath = @"C:\TestFiles\001.mp4";
var lib = new LibVLC();
player.MediaPlayer = new MediaPlayer(lib);
player.MediaPlayer.Play(new Media(lib, filePath));
}
}
}