jsp页面怎么用javascript调用系统录音,然后上传到服务器????
解决方案 »
- 【请教】PMagic安装错误代码117,“Partition's Drive Letter cannot be identified”
- 诚心求一正则表达式
- 很复杂的正则表达式,要考虑几种条件
- 请教大家一个关于iframe的问题,急
- 如何使一个input文本框随其中内容而变化长度?
- 年月日联动,为何每年2月份的日期显示不出来,其他月份是正常的
- 请问 <iframe src="dd.html?dd=dddddddd"</form> 在dd.html中怎样接收dd变量的值。
- 框架网页中怎么限制框架的最小大小?
- 如何限制文本框只能输入数字(包括小数点),而且限制长度
- 请问javascript高手,急
- JavaScript如何向HTML中输出自定义函数
- js图片滚动问题
WshShell = new ActiveXObject("Wscript.Shell")
WshShell.Run("sndrec32.exe")
import javax.sound.sampled.*;
import java.net.*;
/**
* Title: VoiceChat
* Description: 音频捕捉(录音程序)
* Copyright: Copyright (c) 2001
* Company:
* @author 你猜!
* @version 1.0
*/
class Capture implements Runnable {
TargetDataLine line;
Thread thread;
Socket s;
BufferedOutputStream captrueOutputStream;
Capture(Socket s){//构造器 取得socket以获得网络输出流
this.s=s;
}
public void start() {
thread = new Thread(this);
thread.setName("Capture");
thread.start();
}
public void stop() {
thread = null;
}
public void run() {
try {
captrueOutputStream=new BufferedOutputStream(s.getOutputStream());//建立输出流 此处可以加套压缩流用来压缩数据
}
catch (IOException ex) {
return;
}
AudioFormat format =new AudioFormat(8000,16,2,true,true);//AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)
DataLine.Info info = new DataLine.Info(TargetDataLine.class,format);
try {
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format, line.getBufferSize());
} catch (Exception ex) {
return;
}
byte[] data = new byte[1024];//此处的1024可以情况进行调整,应跟下面的1024应保持一致
int numBytesRead=0;
line.start();
while (thread != null) {
numBytesRead = line.read(data, 0,1024);//取数据(1024)的大小直接关系到传输的速度,一般越小越快,
try {
captrueOutputStream.write(data, 0, numBytesRead);//写入网络流
}
catch (Exception ex) {
break;
}
}
line.stop();
line.close();
line = null;
try {
captrueOutputStream.flush();
captrueOutputStream.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
这是Applet程序在网页中调用。
<html>
<applet code=Capture.class width=320 height=270></applet>
</html>
已经过时了 code要的地址谁知道啊 好像有地址就能调用上面的那个类了 不过 不知道地址是什么啊 大虾们 帮帮忙啊