MediaRecorder.stop
收藏我的收藏
结束录制。真正结束录制写入文件完成后会触发注册的
MediaRecorder.onstop
回调。stop
后无法重新调用start
。语法
MediaRecorder.stop()
参数说明
无
返回值
无
扫码体验
代码示例
<canvas id="myCanvas" canvas-id="myCanvas" type="2d"> </canvas> <button type="primary" bindtap="stop">结束录制</button>
Page({ async onReady() { tt.createSelectorQuery() .select("#myCanvas") .node() .exec((res) => { // 获取 canvas 实例 const canvas = res[0].node; const canvasCtx = canvas.getContext("2d"); this.recorder = tt.createMediaRecorder(canvas, { width: canvas.width, // video width height: canvas.height, // video height videoBitsPerSecond: 1000, // bit rate in kbps gop: 12, // key frame interval fps: 60, // frames per second }); }); }, stop() { this.recorder.stop(); tt.showToast({ title: "stop", icon: "none", }); }, });
Bug & Tip
无