能否给出api让小弟试试,小弟我才书学浅,正在学习中.....
解决方案 »
- 关于hibernate多对多双向映射的一些问题
- 取属性的类型的问题
- 重新生成同一个webservice client再执行新方法时出错
- SPRING SECURITY怎么注册后变为登陆状态
- 高手帮我看看这个什么错!谢谢
- 用ANT编译hibernate的java工程时出现找不到符号问题,请高手帮帮小弟!!!
- 请教学习Spring的方法
- 大家又没有参加java开源项目的啊?推荐推荐
- web界面的工作流处理用什么框架比较好?
- hql查询问题:都来看看 这个怎么解释。
- 有没有人知道对方服务器如果是C写的,socket通信对方是接收字符数组还是什么方式?
- 哪位有jbuilder2005的教程啊?100分
import java.awt.*;public class TestPlayer {
boolean packFrame = false;
public TestPlayer() {
TestFrame frame = new TestFrame();
frame.validate();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
} public static void main(String[] args) {
new TestPlayer();
}
}以上推荐的网站有详细的说明,希望楼主留意
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import java.io.IOException;
import java.io.File;public class BasicPlayer { private AudioInputStream stream = null;
private AudioFormat format = null;
private Clip clip = null;
private SourceDataLine m_line; public void play(File fileName,int itemStatus)
{
try {
// From file
stream = AudioSystem.getAudioInputStream(fileName); // At present, ALAW and ULAW encodings must be converted
// to PCM_SIGNED before it can be played
format = stream.getFormat();
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
format = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
16,
format.getChannels(),
format.getChannels() * 2,
format.getSampleRate(),
false); // big endian
stream = AudioSystem.getAudioInputStream(format, stream);
} // Create the clip
DataLine.Info info = new DataLine.Info(SourceDataLine.class, stream.getFormat(), AudioSystem.NOT_SPECIFIED);
m_line = (SourceDataLine) AudioSystem.getLine(info);
m_line.open(stream.getFormat(),m_line.getBufferSize());
m_line.start(); int numRead = 0;
byte[] buf = new byte[m_line.getBufferSize()];
while ((numRead = stream.read(buf, 0, buf.length)) >= 0) {
int offset = 0;
while (offset < numRead) {
offset += m_line.write(buf, offset, numRead-offset);
}
}
m_line.drain();
m_line.stop();
m_line.close();
stream.close();
} catch (IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
}
} public double getDuration()
{
return m_line.getBufferSize() /
(m_line.getFormat().getFrameSize() * m_line.getFormat().getFrameRate());
} public double getDecision()
{
return m_line.getMicrosecondPosition()/1000.0;
}
}