pedroSG94 / vlc-example-streamplayer

Example code how to play a stream with VLC
GNU General Public License v3.0
227 stars 93 forks source link

mute/unmute audio #25

Open royherma opened 5 years ago

royherma commented 5 years ago

Is there a way to toggle audio level (mute/unmute) while its playing?

Thanks!

pedroSG94 commented 5 years ago

Try modify this class: https://github.com/pedroSG94/vlc-example-streamplayer/blob/master/pedrovlc/src/main/java/com/pedro/vlc/VlcVideoLibrary.java

I think the range is 0-100. Example (not tested):

  public void mute() {
    if (player != null && player.isPlaying()) {
      player.setVolume(0);
    }
  }
smartyw commented 3 years ago

Works for me when called from onComplete(). Thanks!

  @Override
  public void onComplete() {
    vlcVideoLibrary.mute();
    Log.d(TAG, "Muting audio");
    Toast.makeText(this, "Playing", Toast.LENGTH_SHORT).show();
  }