- JS API 列表
- 基础
- 网络
- 媒体
- 地图
- 文件
- 开放接口
- 数据缓存
- 地理位置
- 设备
- 画布
- 界面
- 页面导航
- 侧边栏能力
- 行业开放
- AI/AR能力
- 第三方平台
- TTML
- 转发和挂载
- 其它
- 直播能力
MediaRecorder.onStart收藏我的收藏
收藏
我的收藏监听录制开始事件。
语法
Plain Text复制MediaRecorder.onStart(callback)
参数说明
callback
类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
funtion | | 是 | 录制器开始录制后要执行的回调 | 2.52.0 |
返回值
无
扫码体验
代码示例
html复制<canvas id="myCanvas" canvas-id="myCanvas" type="2d"> </canvas>
<button type="primary" bindtap="start">开始录制</button>
js复制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
});
this.recorder.onStart(() => {
tt.showToast({
title: "start",
icon: "none",
});
});
});
},
start() {
this.recorder.start();
},
});
Bug & Tip
无
点击纠错