屏幕录制、截屏

您所在的位置:网站首页 安卓原生怎么截屏 屏幕录制、截屏

屏幕录制、截屏

2024-07-12 03:12| 来源: 网络整理| 查看: 265

更新记录 1.5.0(2022-11-10)

新增删除文件

1.4.5(2022-08-30)

修复停止录屏的回调在开始录屏的回调中回调

1.4.3(2022-08-24)

优化异常捕获模块

查看更多 平台兼容性 Android Android CPU类型 iOS 适用版本区间:5.0 - 11.0 armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 × 原生插件通用使用流程: 购买插件,选择该插件绑定的项目。 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。 开发完毕后正式云打包

付费原生插件目前不支持离线打包。 Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择

问题 ==如果录制不成功,检查 targetSdkVersion 版本是否小于 等于28,大于28有可能会报错==(此问题由微信昵称:【養楽多】提供)

==截屏不刷新图库,检查路径名称是否重复,重复则不会刷新图库;上面的配置也会导致截图报错==

调用函数 函数名 参数 说明 startScreenRecord 见传参,回调 开始屏幕录制 stopScreenRecord 回调 结束屏幕录制 openScreenShot 无 开启截屏 closeScreenShot 无 禁用截屏 screenshot 见传参 截屏 screenshotCamera 见传参 超级截屏 openScreenShotListener 无 开启截屏监听 closeScreenShotListener 无 禁用截屏监听 传参 录屏部分 参数名 类型 说明 默认值 recordWidth int 录制宽度 屏幕宽度 recordHeight int 录制高度 屏幕高度 bitRate int 比特率 width x height x 3.6 frameRate int 帧速率 30 audioSamplingRate int 音频采样率 无 audioBitRate int 音频比特率 无 maxMinute int 最大录制分钟数 30 filePath string 文件路径 根目录:/storage/emulated/0 fileName string 文件名 时间格式化:yyyyMMddHHmmssSSS mute boolean 静音 false 截屏部分 参数名 类型 说明 默认值 path string 图片路径 时间格式化:yyyyMMddHHmmssSSS.png 返回参数 参数 必选 类型 说明 code 是 int 返回码 message 是 string 返回信息 data 否 string 路径 示例代码 const vipRecord = uni.requireNativePlugin('vip-record'); //开始录制(注意此配置仅为了演示配置方式,不是最佳配置参数,最佳参数是默认值(也就是什么都不配置)) vipRecord.startScreenRecord({ "recordWidth":480, "recordHeight":800 "bitRate":300000, "frameRate":35, "audioSamplingRate":96000, "audioBitRate":96000, "maxMinute":60, "fileName":"test", "mute":true },(res)=>{ uni.showToast({ title: JSON.stringify(res), icon:'none'}); }) //停止录制 vipRecord.stopScreenRecord((res)=>{ uni.showToast({ title: JSON.stringify(res), icon:'none'}); }) //开启截屏 vipRecord.openScreenShot(res=>{ uni.showModal({ title:'openScreenShot', content:JSON.stringify(res) }) }) //截屏 vipRecord.screenshot({ path:'/storage/emulated/0/2.jpg' },res=>{ uni.showModal({ title:'screenshot', content:JSON.stringify(res) }) }) //超级截屏 vipRecord.screenshotCamera({ path:'/storage/emulated/0/2.jpg' },res=>{ uni.showModal({ title:'screenshotCamera', content:JSON.stringify(res) }) }) 完整代码

==以下是 script 脚本种的代码,可完整复制使用==

const vipRecord = uni.requireNativePlugin('vip-record'); export default { data() { return { title: 'Hello', backText:'' } }, onLoad() { }, methods: { startRecord(){ //开始录制 vipRecord.startScreenRecord({ "filePath":"/storage/emulated/0/recordVideo", "compatible":true },(res)=>{ uni.showToast({ title: JSON.stringify(res), icon:'none'}); }) }, stopRecord(){ vipRecord.stopScreenRecord((res)=>{ uni.showToast({ title: '已停止录制', icon:'none'}); }) }, startShotScreen(){ vipRecord.screenshot({ path:"/storage/emulated/0/test.jpg" },res=>{ uni.showToast({ title: '截屏成功1', icon:'none'}); }) }, startShotScreen2(){ vipRecord.screenshotCamera({ path:"/storage/emulated/0/test.jpg" },res=>{ uni.showToast({ title: '截屏成功2', icon:'none'}); }) } } }


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3