当前位置: 首页>>代码示例>>Java>>正文


Java AudioStream类代码示例

本文整理汇总了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());
    }
}
 
开发者ID:EhWhoAmI,项目名称:Monster-Quest,代码行数:21,代码来源:MonsterQuestMain.java

示例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();
}
 
开发者ID:ScreenBasedSimulator,项目名称:ScreenBasedSimulator,代码行数:17,代码来源:Sound.java

示例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!");
    }
}
 
开发者ID:tgharib,项目名称:PrayerApp,代码行数:26,代码来源:Program.java

示例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!");
    }
}
 
开发者ID:tgharib,项目名称:PrayerApp,代码行数:27,代码来源:Program.java

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

	}
}
 
开发者ID:coddo,项目名称:TeamSubb,代码行数:17,代码来源:SoundPlayer.java

示例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();
  }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:22,代码来源:DialSoundManager.java

示例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());
    }
}
 
开发者ID:MiroslavJelaska,项目名称:SpaceInvaders,代码行数:12,代码来源:SoundEffectPlayer.java

示例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();
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:33,代码来源:DialSoundManager.java


注:本文中的sun.audio.AudioStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。