Skip to content

Commit

Permalink
修改文档
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuecn committed Sep 4, 2019
1 parent b80066d commit fdac039
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ set={
,onProcess:NOOP //接收到录音数据时的回调函数:fn(buffers,powerLevel,bufferDuration,bufferSampleRate)
//buffers=[[Int16,...],...]:缓冲的PCM数据,为从开始录音到现在的所有pcm片段;powerLevel:当前缓冲的音量级别0-100,bufferDuration:已缓冲时长,bufferSampleRate:缓冲使用的采样率(当type支持边录边转码(Worker)时,此采样率和设置的采样率相同,否则不一定相同)
//如果需要绘制波形之类功能,需要实现此方法即可,使用以计算好的powerLevel可以实现音量大小的直观展示,使用buffers可以达到更高级效果
//注意,此回调可能会在buffers里面添加了多段数据才回调一次,在使用buffers应留意此问题;另外buffers数据的采样率为浏览器提供的原始采样率,和set.sampleRate不一定相同,如需强一致,请在onProcess中自行连续调用采样率转换函数Recorder.SampleData(),配合mock方法可实现实时转码和压缩语音传输
//注意,buffers数据的采样率和set.sampleRate不一定相同,可能为浏览器提供的原始采样率,也可能为已转换好的采样率set.sampleRate;如需浏览器原始采样率的数据,请使用rec.buffers数据,而不是本回调的参数;如需明确和set.sampleRate完全相同采样率的数据,请在onProcess中自行连续调用采样率转换函数Recorder.SampleData(),配合mock方法可实现实时转码和压缩语音传输
}
```

Expand Down
17 changes: 13 additions & 4 deletions assets/zdemo.index.webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Recorder.Support();//激活Recorder.Ctx
,' <style>'
,' .webrtcMsgOut,.webrtcMsgIn{'
,' display: inline-block;'
,' max-width: 220px;'
,' clear: both;'
,' padding: 6px 10px;'
,' border-radius: 10px;'
Expand Down Expand Up @@ -179,7 +180,7 @@ $("body").bind("mousedown touchstart",function(e){
};
rtcVoiceDownEvent=e;

$("body").css("user-select","none");//kill all 免得渣渣浏览器里面复制搜索各种弹
$("body").css("user-select","none");//kill all 免得渣渣浏览器里面复制搜索各种弹,这些浏览器单独给div设置是没有用的

rtcVoiceDownHit=setTimeout(function(){
rtcVoiceStart=true;
Expand Down Expand Up @@ -270,9 +271,9 @@ function webrtcStreamSend(blob,info){
reader.readAsDataURL(blob);
};

function webrtcMessageSend(){
function webrtcMessageSend(txt){
var input=$(".webrtcMsgInput");
var txt=input.val();
txt=txt||input.val();
rtcMsgView(txt,false);

if(rtcChannelOpen){
Expand Down Expand Up @@ -397,7 +398,7 @@ var rtcStatusView=function(){
ctrl="<span style='color:#f60'>连接已关闭,停止数据收发</span>";
};

html.push('<div>发送:'+rtcSendMime+" "+rtcSendLen+"b "+rtcSendCount+"片 共"+rtcBitF(rtcSendSize)+" Skip:"+rtcSendSkip+"片 "+ctrl+"</div>");
html.push('<div style="padding-top:10px">发送:'+rtcSendMime+" "+rtcSendLen+"b "+rtcSendCount+"片 共"+rtcBitF(rtcSendSize)+" Skip:"+rtcSendSkip+"片 "+ctrl+"</div>");
html.push('<div>接收:'+rtcRecMime+" "+rtcRecLen+"b "+rtcRecCount+"片 共"+rtcBitF(rtcRecSize)+" Skip:"+rtcRecSkip+"片 PlayMode:"+rtcPlayMode+"</div>");

rtcStatus.html(html.join("\n"));
Expand Down Expand Up @@ -679,6 +680,14 @@ function webrtcConnect(){
console.log("连接已建立");
reclog("<span style='color:#0b1'>连接已建立,可以开始录音啦</span>");
webrtcOpen();

if(isLocal){
setTimeout(function(){
webrtcMessageSend("# Hello \n - 你可以随时开始录音,会以通话形式实时传送给我 \n - 按住发语音可以发送一个语音消息");
},100);
}else{
webrtcMessageSend("Me too! 太长了就不copy了");
};
};
rtcChannel.onclose=function(){
rtcChannelOpen=0;
Expand Down

0 comments on commit fdac039

Please sign in to comment.