0

I have 4 VlcControls which I used WindowsFormsHost to host them in my WPF page.The VlcControls are to playing video capture cards input content. When I adjust the volume of one in them like below, all 4 Controls' volume get louder/smaller together.Does any of you guys know how to adjust only one VlcControl's volume instead of 4 together?

// Set options
string[] options = new string[]
{
   $":dshow-vdev={videoDeviceName}",
   $":dshow-adev={audioDeviceName}",
   ":dshow-size=1920x1080",
   ":dshow-aspect-ratio=16\\:9",
   ":dshow-fps=60",
   ":live-caching=0",
   ":width=960",
   ":height=540",
   ":transform-type=180",
};

// Start to Play
vlcControls[1].Play("dshow://", options);

// Adjust the volume
private void ChangeVolumn(object para2)
{
    var volume = (double)para2;
    var player = vlcControls[1];
    player.Audio.Volume = (int)volume;
}

I tried:

player.MediaPlayer.Audio.Volume = (int)volume;

but I found they were the same.

  • Your code doesn't compile, `volume` is a parameter of `ChangeVolumn` and is redefined by `var volume = double.Parse(para2);`, maybe the issue is here. – Orace Apr 17 '23 at 12:06
  • VLC uses per-application volume control. Fixing this is a major overhaul of the VLC code, unlikely to be practical. – Hans Passant Apr 17 '23 at 16:17
  • @Orace Yes, you were right. I made a mistake when I edit my source onto this page, because my parameter was passed here as an object type. I fixed it just now. – Marvin Wilson Apr 18 '23 at 03:49
  • @HansPassant But when I use VLC Player, multiple players and play different content, the volume can be adjusted separately. I thought it also could be done by C# code. really cannot? – Marvin Wilson Apr 18 '23 at 03:56

1 Answers1

0

This seems to be a known bug that has never been reported on the VideoLAN bug tracker

The issue it that the mmdevice audio output plugin only has a shared volume value, instead of a per-player one.

as a workaround, you could use a different audio output module, by passing this option to the libvlc constructor

--aout=directsound

Sources:

cube45
  • 3,429
  • 2
  • 24
  • 35
  • This solved my problem perfectly! I just add a new line into my "options[]" and it's working for me now. The new line is ":aout=directsound" – Marvin Wilson Apr 20 '23 at 01:39