title: How to set Videoview Volume Programmatically?
body: <p>I have 4 Videoview which is created dynamically. I want to set a custom volume for only one video which is coming from the server, the remaining three videos will be mute.</p>
  
  <p>I want to set a custom volume for particular videos I tried below code it's not working</p>
  
  <pre><code> vid1.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
                  {
                      public void onPrepared(MediaPlayer mp)
                      {
                       //mp.setVolume(100f, 100f);
                       //mp.setLooping(true);
                       vid1.enableSound(20,mp); //here i will set music sound dynamically
                       vid1.start();
                       playingvideo1 = true;
                      }
                  });
                  //startTimeForContent = dateFormatForContent.format(new Date());
                  vid1.setOnErrorListener(mOnErrorListener2);
                  playBackfunction1();
              }
  </code></pre>
  
  <hr>
  
  <pre><code>public void enableSound(int sound, MediaPlayer mp){
          Float f = Float.valueOf(sound);
          Log.e("checkingsounds","&amp;&amp;&amp;&amp;&amp;   "+f);
          mp.setVolume(f,f);
          mp.setLooping(true);
          AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
          audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
          audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
          audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, sound, AudioManager.FLAG_PLAY_SOUND);
      }
  </code></pre>
  
  <p><strong>When I give volume 0 it is working...but when change 10,20,30 video is playing full sound....</strong></p>
  
  <p>I already research below:</p>
  
  <p><a href="https://stackoverflow.com/questions/28613587/sound-volume-not-working-on-android?noredirect=1&amp;lq=1">sound volume not working on Android</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10134338/using-seekbar-to-control-volume-in-android">Using SeekBar to Control Volume in android?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38482760/how-to-increase-and-decrease-volume-in-android?noredirect=1&amp;lq=1">How to increase and decrease volume in android</a></p>