当前位置: 首页 > 工具软件 > Audiostream > 使用案例 >

audiostream java_Java AudioStream類代碼示例

施选
2023-12-01

本文整理匯總了Java中sun.audio.AudioStream類的典型用法代碼示例。如果您正苦於以下問題:Java AudioStream類的具體用法?Java AudioStream怎麽用?Java AudioStream使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

AudioStream類屬於sun.audio包,在下文中一共展示了AudioStream類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: playSound

​點讚 3

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());

}

}

開發者ID:EhWhoAmI,項目名稱:Monster-Quest,代碼行數:21,

示例2: play

​點讚 3

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();

}

開發者ID:ScreenBasedSimulator,項目名稱:ScreenBasedSimulator,代碼行數:17,

示例3: displayStartPrayerRemindersIfNeeded

​點讚 3

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!");

}

}

開發者ID:tgharib,項目名稱:PrayerApp,代碼行數:26,

示例4: displayEndPrayerRemindersIfNeeded

​點讚 3

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!");

}

}

開發者ID:tgharib,項目名稱:PrayerApp,代碼行數:27,

示例5: playSound

​點讚 3

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) {

}

}

開發者ID:coddo,項目名稱:TeamSubb,代碼行數:17,

示例6: initializeAudioStream

​點讚 3

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();

}

}

開發者ID:visit,項目名稱:spark-svn-mirror,代碼行數:22,

示例7: Play

​點讚 2

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());

}

}

開發者ID:MiroslavJelaska,項目名稱:SpaceInvaders,代碼行數:12,

示例8: DialSoundManager

​點讚 2

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();

}

開發者ID:visit,項目名稱:spark-svn-mirror,代碼行數:33,

注:本文中的sun.audio.AudioStream類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

 类似资料: