c# - Vlc.DotNet - Not able to set the volume before playing an audio -


i downloaded vlc.dotnet project github , have been adding more functionalities sample forms application. goes fine, except on thing: noticed every time start application , play audio, audio sounds volume 100% (or around that) - after set lower value.

i tried setting volume before playing audio, didn't work. if debug code, see volume set -1.

for instance, if execute following lines of code, after setting volume 40, when debug it, volume still -1:

myvlccontrol.play(new fileinfo(filename)); myvlccontrol.audio.volume = 40;  

change order of lines above doesn't work.

the funny thing is, when audio playing , change volume,it changed select value on numericupdown. code below event happens:

private void numericupdown1_valuechanged(object sender, eventargs e) {     myvlccontrol.audio.volume = (int)numericupdown1.value; } 

i've been trying solve problem 2 days now. unfortunately, coding skills not close people behind project. have posted problem on issues page on github, since there questions since november without replies, decided try stackoverflow. here uses vlc.dotnet , have solution problem.

that being said:

  • does have same problem?
  • does know how solve it?
  • any suggestions?

thanks!

[edit on jan 8, 2016, 11:50 gmt-2]

the user higankanshi on github answered me following:

i have found problem. should use libvlc 2.2.0(or later). vlc.dotnet using libvlc 2.1.5

then, executed tests , came following conclusions:

you're right. using libvlc 2.2.0 i'm able set volume before playing.

unfortunately, reason, setting volume before playing audio works on first time application opened. after stopping audio, changing volume, , playing again, volume doesn't change anymore - changes while playing.

here steps results:

  1. execute application;
  2. change volume @ run time before playing audio file;
  3. play audio file;
    • result: audio plays @ specified volume, successfully! =)
  4. press stop;
  5. change volume again;
  6. press play again (at point, implementation inside play method should new volume information);
    • result: audio plays again @ same volume played before. setting volume doesn't work anymore.

i'm doing tests on vlc.dotnet.forms.samples - clr 4 - .net 4.5 project. changes i've made project were:

  • added numericupdown control, change volume @ run time;
  • associated valuechanged event numericupdown control, every time changes value, new value passed vlccontrol;
  • created play() function gets last volume value before playing audio;

my code below:

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(); } 

any ideas?

i have found working solution:

int volume { get; set; }  public constructor(){     initializecomponent();     myvlccontrol.videooutchanged += myvlccontrol_videooutchanged; }  private void numericupdown1_valuechanged(object sender, eventargs e) {     this.volume = (int)numericupdown1.value;     myvlccontrol.audio.volume = volume; }  void vlcplayer_videooutchanged(object sender, vlcmediaplayervideooutchangedeventargs e) {     myvlccontrol.audio.volume = volume; } 

this seems work both file , stream.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -