I am using Vlc.DotNet.Forms package in my project. I open one video on form. Everything okay. But If I want to open a video again. When I change the volume, the volume of both videos changes.
My Code Example:
public VlcControl control;
public void Player(string url,int volume){
this.control = new VlcControl();
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
control.BeginInit();
control.VlcLibDirectory = libDirectory;
control.Dock = DockStyle.Fill;
control.EndInit();
this.Controls.Add(control);
control.SetMedia(new Uri(@"" + url + ""));
control.Audio.Volume=volume;
control.Play();
}
For example,
Player("C:\\test\video1.mp4",50);
Player("C:\\test\video2.mp4",75);
The first video opens and the volume becomes 50. Then when I open the second video, the volume of both videos is 75.
I use these packages
This seems to be a known issue of libvlc 3.x.
The workaround is to use a different audio output. In Vlc.DotNet, you can do so like this:
control.VlcMediaplayerOptions = new []{ "--aout=directsound" };
Before control.EndInit();
.
References: