📄 voicethread.java
字号:
/*
* VocieThread.java
*
* Created on 2006年8月14日, 下午6:41
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.gamvan.club.users.im.client.personalchat;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import org.jsresources.apps.am.audio.AudioCapture;
import org.jsresources.apps.am.audio.AudioPlayStream;
/**
*
* @author Administer
*/
public class VoiceThread extends Thread {
/** Creates a new instance of VocieThread */
//private ObjectInputStream dataIn = null;
private ObjectOutputStream dataOut = null;
private AudioCapture PhoneMIC = null; // @jve:decl-index=0:
//private AudioPlayStream PhoneSPK = null;
//private Socket clientSocket = null;
public boolean isOver = false;
public VoiceThread() {
}
public void run(){
try {
//播放声音,捕捉声音
catchVoice();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/*
*捕获本地的声音
*并且将数据发送出去
*/
private void catchVoice() throws IOException{
int b = 0;
int bufSize = PhoneMIC.getBufferSizeInBytes();
byte[] compressedVoice = new byte[bufSize];
InputStream myIStream = null;
myIStream = PhoneMIC.getAudioInputStream();
while((!Thread.interrupted())&&!isOver){
System.out.print("12345678");
b = myIStream.read(compressedVoice,0, bufSize);
}
//发送标示符
dataOut.writeObject("语音数据");
dataOut.flush();
System.out.println("ewewewew");
dataOut.write(compressedVoice,0,b);
dataOut.flush();
}
public void sendObjects(Socket clientSocket,ObjectInputStream dataIn,ObjectOutputStream dataOut,
AudioPlayStream PhoneSPK, AudioCapture PhoneMIC){
//this.dataIn =dataIn;
this.dataOut = dataOut;
this.PhoneMIC = PhoneMIC;
//this.PhoneSPK = PhoneSPK;
//this.clientSocket = clientSocket;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -