本文整理汇总了Java中sun.audio.AudioStream类的典型用法代码示例。如果您正苦于以下问题:Java AudioStream类的具体用法?Java AudioStream怎么用?Java AudioStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AudioStream类属于sun.audio包,在下文中一共展示了AudioStream类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playSound
import sun.audio.AudioStream; //导入依赖的package包/类
/**
* This plays the sound specified in the parameters.
* @param soundFileName The file name for the sound file
*/
static void playSound (String soundFileName) {
try {
String soundFile = (System.getProperty("user.dir") + soundFileName);
InputStream in = new FileInputStream(soundFile);
// create an audiostream from the inputstream
AudioStream audioStream = new AudioStream(in);
// play the audio clip with the audioplayer class
systemLog.log("Loading sound...");
AudioPlayer.player.start(audioStream);
} catch (FileNotFoundException fnfe) {
systemLog.log("Unable to open file! " + fnfe.getMessage());
} catch (IOException ioe) {
systemLog.log("IO error! " + ioe.getMessage());
}
}
示例2: play
import sun.audio.AudioStream; //导入依赖的package包/类
public static void play(String s) throws Exception {
String gongFile = null;
// open the sound file as a Java input stream
if (s.equals("alarm")) {
gongFile = "src/test/resources/media/alarm.wav";
}
InputStream in = new FileInputStream(gongFile);
// create an audiostream from the inputstream
audioStream = new AudioStream(in);
// play the audio clip with the audioplayer class
AudioPlayer.player.start(audioStream);
// return audioStream;
// audioStream.close();
}
示例3: displayStartPrayerRemindersIfNeeded
import sun.audio.AudioStream; //导入依赖的package包/类
private void displayStartPrayerRemindersIfNeeded() {
PrayerInterval interval = null;
if (fajrInterval.currentlyStarting()) {
interval = fajrInterval;
} else if (dhuhrInterval.currentlyStarting()) {
interval = dhuhrInterval;
} else if (asrInterval.currentlyStarting()) {
interval = asrInterval;
} else if (maghribInterval.currentlyStarting()) {
interval = maghribInterval;
} else if (ishaInterval.currentlyStarting()) {
interval = ishaInterval;
}
if (interval != null) {
try {
AudioPlayer.player.start(new AudioStream(ClassLoader.getSystemClassLoader().getResourceAsStream("notification.wav")));
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
showWarningDialog(interval.getPrayerEnum().toString() + " prayer has started! Do not forget to count the correct number of rakat!");
}
}
示例4: displayEndPrayerRemindersIfNeeded
import sun.audio.AudioStream; //导入依赖的package包/类
private void displayEndPrayerRemindersIfNeeded() {
PrayerInterval interval = null;
if (fajrInterval.endsWithinXMins(Settings.INT_MINUTES_WARNING)) {
interval = fajrInterval;
} else if (dhuhrInterval.endsWithinXMins(Settings.INT_MINUTES_WARNING)) {
interval = dhuhrInterval;
} else if (asrInterval.endsWithinXMins(Settings.INT_MINUTES_WARNING)) {
interval = asrInterval;
} else if (maghribInterval.endsWithinXMins(Settings.INT_MINUTES_WARNING)) {
interval = maghribInterval;
} else if (ishaInterval.endsWithinXMins(Settings.INT_MINUTES_WARNING)) {
interval = ishaInterval;
}
if (interval != null) {
try {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("notification.wav");
AudioPlayer.player.start(new AudioStream(inputStream));
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
}
showWarningDialog(interval.getPrayerEnum().toString() + " prayer ends within " + Settings.INT_MINUTES_WARNING + " minutes! Do not forget to count the correct number of rakat!");
}
}
示例5: playSound
import sun.audio.AudioStream; //导入依赖的package包/类
private static void playSound(String soundFile) {
try {
// open the sound file as a Java input stream
InputStream in = new FileInputStream(soundFile);
// create an audiostream from the inputstream
AudioStream audioStream = new AudioStream(in);
// play the audio clip with the audioplayer class
AudioPlayer.player.start(audioStream);
}
catch (Exception ex) {
}
}
示例6: initializeAudioStream
import sun.audio.AudioStream; //导入依赖的package包/类
private void initializeAudioStream(int i) {
try {
if (audioStreams[i] != null) {
audioStreams[i].close();
audioStreams[i] = null;
}
InputStreamEventSource is = new InputStreamEventSource(i,
PhoneRes.getURL("DTMF" + i + "_SOUND").openStream());
is.addListener(new InputStreamListener() {
@Override
public void handleEndOfStream(int n) {
initializeAudioStream(n);
}
});
audioStreams[i] = new AudioStream(is);
}
catch (IOException e) {
e.printStackTrace();
}
}
示例7: Play
import sun.audio.AudioStream; //导入依赖的package包/类
public static void Play(String filePath){
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream in = cl.getResourceAsStream(filePath);
AudioStream audioStream = new AudioStream(in);
AudioPlayer.player.start(audioStream);
}
catch (Exception e){
System.out.println("Sound error:" + e.getMessage());
}
}
示例8: DialSoundManager
import sun.audio.AudioStream; //导入依赖的package包/类
public DialSoundManager() {
audioStreams = new AudioStream[12];
for (int i = 0; i < 12; i++) {
initializeAudioStream(i);
}
playerThread = new Thread(new Runnable() {
@Override
public void run() {
while (running) {
try {
if (playQueue.size() == 0) {
synchronized(playQueue) {
playQueue.wait();
}
continue;
}
play(playQueue.remove(0));
Thread.sleep(40);
}
catch (InterruptedException ex) {
if (running == false) {
break;
}
}
} // while
}
});
playerThread.start();
}