From 23c4164df812541e03c1d18909057b44f9d45dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B1=86=E8=B1=86?= <753610399@qq.com> Date: Fri, 22 Jun 2018 15:35:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3close=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recorder.js | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/recorder.js b/recorder.js index f077682..74d8cdd 100644 --- a/recorder.js +++ b/recorder.js @@ -21,7 +21,14 @@ function Recorder(set){ return new RecorderFn(set); }; Recorder.IsOpen=function(){ - return Recorder.Stream&&!Recorder.Stream.ended; + var stream=Recorder.Stream; + if(stream){ + var tracks=stream.getTracks(); + if(tracks.length>0){ + return tracks[0].readyState=="live"; + }; + }; + return false; }; function RecorderFn(set){ this.set=$.extend({ @@ -87,12 +94,26 @@ RecorderFn.prototype={ Recorder.Stream=0; call(); }; - if(!Recorder.IsOpen()||!Recorder.Stream.stop){//新版本无需关闭? - fn(); - }else{ - Recorder.Stream.onended=fn; - Recorder.Stream.stop(); + + var stream=Recorder.Stream; + if(stream){ + var tracks=Recorder.Stream.getTracks(); + if(tracks.length>0){ + var t0=tracks[0]; + if(t0.readyState=="live"){ + t0.onended=fn; + t0=0; + }; + for(var i=0;i