InputStream in = new FileInputStream(fileName);
AudioStream audio = new AudioStream(in);
AudioData data = audio.getData();
ContinuousAudioDataStream conAudio = new ContinuousAudioDataStream (data);
AudioPlayer.player.start (conAudio);
AudioStream audio = new AudioStream(in);
AudioData data = audio.getData();
ContinuousAudioDataStream conAudio = new ContinuousAudioDataStream (data);
AudioPlayer.player.start (conAudio);
解决方案 »
- 关于这句SQL语句的错误
- 急~在线等,label上图片移动问题
- jbuilder中怎么样把sqljdbc.jar导入项目里面
- 学习JAVA,要有什么样的基础呀??
- 对JNDI熟悉的朋友进来一下,InitialContext(Hashtable environment) 方面的问题。
- 有没有办法不让tomcat出下面这个提示
- Scioworks Camino3.02和jdk版本的问题.
- (关于c/s问题)各位高手我写了c/s结构的程序,Server是采用Java写的,Client是采用VC写的,详情请进来看看!
- 超级大难题!!!
- super 问题
- 请教:jcombobox判断空值问题(在线等)
- 大家都用哪些IDE开发?
String audioName="1.wav";
audio.play();
audio.loop();
audio.stop();
import java.io.*;public class As
{
public static void main(String args[])
{
try {
InputStream in = new FileInputStream("c:\\1.au");
AudioStream audio = new AudioStream(in);
AudioData data = audio.getData();
ContinuousAudioDataStream conAudio = new ContinuousAudioDataStream (data);
AudioPlayer.player.start (conAudio); }
catch (Exception e) {System.out.println(e);}
}
}
运行的时候也是报的这个错误:
java.io.IOException: could not create audio stream from input stream
Press any key to continue...
好像AudioClip是用于Applet里面的吧。我的是JFrame。
import java.applet.AudioClip;
import java.io.File;
import java.io.IOException;
import java.net.URL;public class AppletSound
{
/**类静态变量*/
private static AppletSound appletSound = null;
/**声音文件路径及名称静态变量*/
private static URL audioURL = null;
/**声音静态变量*/
private static AudioClip audioWAV = null; /**
* 构建器
* <p>加载声音文件。
* @throws IOException
*/
private AppletSound() throws IOException
{
try {
File file = new File("xxx.wav")
audioURL = new URL("file:///" + file.getAbsoluteFile());
audioWAV = Applet.newAudioClip(audioURL);
} catch (IOException ie) {
throw ie;
}
} private static AppletSound getInstance() throws IOException
{
if (null == appletSound) {
appletSound = new AppletSound();
}
return appletSound;
} /**
* 播放声音
* @throws IOException
*/
public static void play() throws IOException
{
getInstance().audioWAV.play();
} /**
* 循环播放
* @throws IOException
*/
public static void loop() throws IOException
{
getInstance().audioWAV.loop();
} /**
* 停止播放
* @throws IOException
*/
public static void stop() throws IOException
{
getInstance().audioWAV.stop();
}
}
你指的
一个很讨人厌的家伙说的是张天奢嘛?
错误信息:
C:\Documents and Settings\Administrator\桌面\AppletSound.java:24: illegal character: \65288
File file = new File("1.au");
^
1 error
另外可以先用AIS,再转换成AS试一下
AudioInputStream ais= new AudioStream(in);