-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.java
35 lines (32 loc) · 1.32 KB
/
audio.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import javax.sound.sampled.*;
public class audio {
public static void main(String[]args) throws UnsupportedAudioFileException, IOException, LineUnavailableException{
Scanner scanner = new Scanner(System.in);
File file = new File("La-Lecon-Particuliere-Bof-La-Lecon-Particuliere.wav");
AudioInputStream audioStream = AudioSystem.getAudioInputStream(file);
Clip clip = AudioSystem.getClip();
clip.open(audioStream);
String response = "";
while(!response.equals("Q")){
System.out.println("P = play, S = Stop, R = Reset, Q = Quit");
System.out.print("Enter your choice : ");
response = scanner.next();
response = response.toUpperCase();
switch(response){
case ("P") : clip.start();
break;
case ("S") : clip.stop();
break;
case ("R") : clip.setMicrosecondPosition(0);
break;
case ("Q") : clip.close();
default : System.out.println("exited with code 019");
}
}
System.out.println("Thank you for using the audio player !peace! ");
scanner.close();
}
}