3 import java
.io
.IOException
;
5 import java
.util
.Scanner
;
7 public class VolumeControl
implements interfaces
.VolumeControl
{
11 public int getVolume() {
13 URL url
= DJ
.class.getResource("getvolume.sh");
16 System
.out
.println("getting volume");
17 Process p
= Runtime
.getRuntime().exec(
18 "bash " + url
.getFile());
19 for (Scanner sc
= new Scanner(p
.getErrorStream()); sc
.hasNextLine();) {
20 System
.out
.println(sc
.nextLine());
22 Scanner sc
= new Scanner(p
.getInputStream());
23 if (sc
.hasNextInt()) {
24 this.volume
= sc
.nextInt();
26 } catch (IOException e
) {
27 System
.err
.println("set volume failed");
34 public void setVolume(int volume
) {
36 URL url
= DJ
.class.getResource("setvolume.sh");
39 System
.out
.println("setting volume to " + volume
);
40 Process p
= Runtime
.getRuntime().exec(
41 "bash " + url
.getFile() + " " + volume
);
42 for (Scanner sc
= new Scanner(p
.getErrorStream()); sc
.hasNextLine();) {
43 System
.out
.println(sc
.nextLine());
45 } catch (IOException e
) {
46 System
.err
.println("set volume failed");