1

How to set the volume in this simple example? I saw different approaches before but I don't know how to adapt them for my simple snippet.

Related Questions:

  1. Changing Volume with JLayer
  2. Changing volume in Java when using JLayer

Code listing:

package view.sound;
import java.io.FileInputStream;

import javazoom.jl.player.Player;

public class Audio extends Thread {

    String fileLocation = "src/EgyptianTavernFullofGuitarists_1.mp3";

    boolean loop = true;

    Player player;

    @Override
    public void run() {
        try {
            do {
                FileInputStream buff = new FileInputStream(fileLocation);
                player = new Player(buff);
                player.play();
            } while (loop);
        } catch (Exception ioe) {
            
        }
    }
    
    public void close(){
        loop = false;
        player.close();
        this.interrupt();
    }

}
Phil Freihofner
  • 7,645
  • 1
  • 20
  • 41
Georodin
  • 191
  • 1
  • 2
  • 14

0 Answers0