91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 813B
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-01
  • 語言: Java
  • 標(biāo)簽: java??播放器??

資源簡介

java sound 簡單播放器,這是我自學(xué)Java Sound后編寫的一個簡單播放程序,另外我還上傳了一個基于Java Sound的錄音程序。

資源截圖

代碼片段和文件信息

package?com.xzz.applet.service;

import?java.io.BufferedInputStream;
import?java.io.IOException;
import?java.net.Socket;

import?javax.sound.sampled.AudioFormat;
import?javax.sound.sampled.AudioSystem;
import?javax.sound.sampled.DataLine;
import?javax.sound.sampled.LineUnavailableException;
import?javax.sound.sampled.SourceDataLine;

public?class?SimpleAudioPlayer?{

public?SourceDataLine?sdLine;
public?AudioFormat?audioFormat;
private?PlayThread?playThread;
private?Socket?soc;
public?boolean?stop?=?true;

public?SimpleAudioPlayer(Socket?soc)?throws?LineUnavailableException?{

audioFormat?=?MyAudioFormat.getInstance();
DataLine.Info?dataLineInfo?=?new?DataLine.Info(SourceDataLine.class
audioFormat);
sdLine?=?(SourceDataLine)?AudioSystem.getLine(dataLineInfo);
sdLine.open();
this.soc?=?soc;
}

public?void?start()?throws?IllegalRecordStateException?{
if?(stop)?{
sdLine.start();
playThread?=?new?PlayThread();
playThread.start();
}?else?{
throw?new?IllegalRecordStateException(
“Illegal?playing?state!?Player?is?active?at?the?time.“);
}
}

public?void?stop()?{
stop?=?true;
playThread.stopService();
playThread?=?null;
sdLine.stop();
}

public?void?close(){

sdLine.close();

}

class?PlayThread?extends?Thread?{

private?BufferedInputStream?in;

@Override
public?void?run()?{

try?{
in?=?new?BufferedInputStream(soc.getInputStream());
}?catch?(IOException?e1)?{
e1.printStackTrace();
}
byte[]?buf?=?new?byte[1024?*?1];

int?readed?=?-1;
try?{
while?(stop)?{

if?((readed?=?in.read(buf))?>?0)?{
sdLine.write(buf?0?readed);
}?else
break;

}
}?catch?(Exception?e)?{
e.printStackTrace();
}
}

public?void?stopService(){
try?{
in.close();
}?catch?(Exception?e)?{
}
}
}
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????1931??2011-02-19?00:18??SimpleAudioPlayer.java

-----------?---------??----------?-----??----

?????????????????1931????????????????????1


評論

共有 條評論