package bookmyshow;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import javax.sound.sampled. AudioFormat;
import javax.sound.sampled. AudioInputStream;
import javax.sound.sampled. AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled. LineListener;
import javax.sound.sampled. LineUnavailableException;
import javax.sound.sampled. UnsupportedAudioFileException;
public class Test {
public static void main(String[] args) throws Exception {
while (true) {
URL myUrl = new URL(
URLConnection yc = myUrl.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc. getInputStream(), "UTF-8"));
String inputLine;
StringBuilder a = new StringBuilder();
while ((inputLine = in.readLine()) != null)
a.append(inputLine);
in.close();
String str1 = a.toString();
boolean result = str1.indexOf("BR Hitech") > 0;
if (result) {
File audioFile = new File("C:\\Users\\KKasthuri\\ Downloads\\aa.wav");
Clip audioClip;
try {
AudioInputStream audioStream = AudioSystem. getAudioInputStream(audioFile) ;
AudioFormat format = audioStream.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
audioClip = (Clip) AudioSystem.getLine(info);
audioClip.open(audioStream);
audioClip.start();
Thread.sleep(10000);
audioClip.close();
} catch (Exception ex) {
System.out.println("Erffdfsg the audio file.");
ex.printStackTrace();
}
System.out.println("theater added");
}
Thread.sleep(5000);
}
}
}
No comments:
Post a Comment