title: Vlc.DotNet - Not able to set the volume before playing an audio
body: <p>I downloaded the Vlc.DotNet project from Github and have been adding more functionalities to its Sample Forms application. Everything goes fine, except on thing: I noticed that every time I start the application and play an audio, the audio sounds like its volume is 100% (or something around that) - even after I set it to a lower value.</p>
  
  <p>I tried setting the volume before playing the audio, but it didn't work.
  If I debug the code, I see that the volume is always set to -1.</p>
  
  <p>For instance, if I execute the following lines of code, after setting the volume to 40, when I debug it, the volume is still -1:</p>
  
  <pre><code>myVlcControl.Play(new FileInfo(FileName));
  myVlcControl.Audio.Volume = 40; 
  </code></pre>
  
  <p>Change the order of the lines above also doesn't work.</p>
  
  <p>The funny thing is, when the audio is already playing and I change the volume,it is successfully changed to the select value on the NumericUpDown. The code below is the event where this happens:</p>
  
  <pre><code>private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  {
      myVlcControl.Audio.Volume = (int)numericUpDown1.Value;
  }
  </code></pre>
  
  <p>I've been trying to solve this problem for two days now. Unfortunately, my coding skills are not even close the people behind this project. I have already posted this problem on their Issues page on Github, but since there are questions since November without replies, I decided to try the StackOverflow. Hopefully someone here uses Vlc.DotNet and have a solution for my problem.</p>
  
  <p>That being said:</p>
  
  <ul>
  <li>Does anyone have the same problem?</li>
  <li>Does anyone know how to solve it?</li>
  <li>Any suggestions?</li>
  </ul>
  
  <p>Thanks! </p>
  
  <p>[EDIT on Jan 8, 2016, 11:50 AM GMT-2]</p>
  
  <p>The user higankanshi on Github answered me the following:</p>
  
  <blockquote>
    <p>I have found the problem.
    You should use LibVlc 2.2.0(or later).
    Vlc.DotNet is using LibVlc 2.1.5</p>
  </blockquote>
  
  <p>Then, I executed some tests and came to the following conclusions:</p>
  
  <p>You're right. Using the LibVlc 2.2.0 I'm able to set the Volume before playing.</p>
  
  <p>Unfortunately, for some reason, setting the volume before playing the audio only works on the first time the application is opened. After stopping the audio, changing the volume, and playing it again, the volume doesn't change anymore - only changes while playing.</p>
  
  <p>Here are the steps with results:</p>
  
  <ol>
  <li>Execute the application;</li>
  <li>Change the volume at run time before playing an audio file;</li>
  <li>Play the audio file;
  
  <ul>
  <li>RESULT: the audio plays at the specified volume, successfully! =)</li>
  </ul></li>
  <li>Press Stop;</li>
  <li>Change the volume again;</li>
  <li>Press Play again (at this point, the implementation inside the play method should get the new volume information);
  
  <ul>
  <li>RESULT: the audio plays again at the same volume it played before. Setting the volume doesn't work anymore.</li>
  </ul></li>
  </ol>
  
  <p>I'm doing my tests on the <strong>Vlc.DotNet.Forms.Samples - CLR 4 - .Net 4.5</strong> project. The changes I've made to the project were:</p>
  
  <ul>
  <li>Added a NumericUpDown control, so that I could change the volume at run time;</li>
  <li>Associated the ValueChanged event to the NumericUpDown control, so that every time it changes the value, the new value is passed to the VlcControl;</li>
  <li>Created a Play() function that always gets the last volume value before playing the audio;</li>
  </ul>
  
  <p>My code is below:</p>
  
  <pre><code>private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  {
      myVlcControl.Audio.Volume = (int)numericUpDown1.Value;
  }
  
  private void Play()
  {
      myVlcControl.Audio.Volume = (int)numericUpDown1.Value;
      myVlcControl.Play(new FileInfo(FileName));
  }
  
  private void OnButtonPlayClicked(object sender, EventArgs e)
  {
      Play();
  }
  
  private void OnButtonStopClicked(object sender, EventArgs e)
  {
      myVlcControl.Stop();
  }
  
  private void OnButtonPauseClicked(object sender, EventArgs e)
  {
      myVlcControl.Pause();
  }
  </code></pre>
  
  <p>Any ideas?</p>