更新记录

1.2.0(2021-11-09)

本次主要更新: 1.修复startRecording_ios11 录屏没有声音的问题

1.1.0(2021-09-16)

本次主要更新: 1.增加ios11录屏方法 2.修复stopRecording ios14,不能获取录屏地址,弹出保存录屏到相册界面

1.0.0(2021-07-02)

首次更新

查看更多

平台兼容性

Android iOS
× 适用版本区间:9 - 16

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
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原生插件配置”->”云端插件“列表中删除该插件重新选择


KJ-ScreenRecorder

应用内录屏(ios)

后台录屏、应用外录屏、直播屏幕(ios):https://ext.dcloud.net.cn/plugin?id=8149

导入插件

    const KJScreenRecorder = uni.requireNativePlugin('KJ-ScreenRecorder');

使用

<template>
    <view>
        <button type="primary" @click="isRecording">是否正在录屏</button>
        <button type="primary" @click="isAvailable">录屏功能是否可用</button>
        <button type="primary" @click="startRecording">开始录屏</button>
        <button type="primary" @click="stopRecording">停止录屏</button>
        <button type="primary" @click="startRecording_ios11">开始录屏ios11</button>
        <button type="primary" @click="stopRecording_ios11">停止录屏ios11</button>
<!--        <video id="myVideo" :src="videoPath" enable-danmu danmu-btn controls></video>
 -->    </view>
</template>

<script>
    Date.prototype.Format = function(fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k])
                    .length)));
            }
        }
        return fmt;
    }

    const KJScreenRecorder = uni.requireNativePlugin('KJ-ScreenRecorder');

    export default {
        data() {
            return {
                videoPath: "file:///var/mobile/Containers/Data/Application/5EED669D-FF11-4BB2-A7B1-29FBE49022A8/Documents/Pandora/apps/__UNI__863F719/doc/KJ-ScreenRecorder/20210630161127.mp4"
            }
        },
        onLoad() {

        },
        onHide: function() {
            console.log('App Hide aaa')
            // KJScreenRecorder.isRecording((res) => {
            //  if(res.result) {
            //      var dic = {
            //          "saveVideoPath": plus.io.convertLocalFileSystemURL("_doc/KJ-ScreenRecorder") + "/" + new Date().Format(
            //              "yyyyMMddhhmmss") + ".mp4" //录屏保存到沙盒的路径
            //      }
            //      KJScreenRecorder.stopRecording(dic, (res) => {
            //          this.videoPath = "file://"+res.videoPath;
            //          console.log("stopRecording: " + JSON.stringify(res));
            //      });
            //  }
            // });
        },
        methods: {
            isRecording() {
                KJScreenRecorder.isRecording((res) => {
                    console.log("isRecording: " + JSON.stringify(res));
                });
            },
            isAvailable() {
                KJScreenRecorder.isAvailable((res) => {
                    console.log("isAvailable: " + JSON.stringify(res));
                });
            },
            startRecording() {
                var dic = {
                    "microphoneEnabled": true //是否启用麦克风
                }
                KJScreenRecorder.startRecording(dic, (res) => {
                    console.log("startRecording: " + JSON.stringify(res));
                }, (res) => {
                    //当因为错误或者是可用性更改而停止录制时会调用这个方法 比如:进入后台,再回到前台
                    //如果在录制的过程中,因为一些意外终止了录制,会调用这个方法,可以再此获取错误信息
                    console.log("didStopRecordingWithError: " + JSON.stringify(res));
                }, (res) => {
                    //用来监听 ReplayKit 是否可用的,如果状态发生变化(比如录制过程中,切入设置,关闭权限。)会回调该方法。
                    console.log("screenRecorderDidChangeAvailability: " + JSON.stringify(res));
                });
            },
            stopRecording() {
                var dic = {
                    "saveVideoPath": plus.io.convertLocalFileSystemURL("_doc/KJ-ScreenRecorder") + "/" + new Date()
                        .Format("yyyyMMddhhmmss") + ".mp4" //录屏保存到沙盒的路径
                }
                //注意:ios14,不能获取录屏地址,弹出保存录屏到相册界面
                KJScreenRecorder.stopRecording(dic, (res) => {
                    this.videoPath = "file://" + res.videoPath;
                    console.log("stopRecording: " + JSON.stringify(res));
                });
            },
            startRecording_ios11() {
                var dic = {
                    "microphoneEnabled": true ,//是否启用麦克风
                    "videoPath": plus.io.convertLocalFileSystemURL("_doc/KJ-ScreenRecorder") + "/" + new Date()
                        .Format("yyyyMMddhhmmss") + ".mp4" //录屏保存到沙盒的路径
                }
                KJScreenRecorder.startRecording_ios11(dic, (res) => {
                    console.log("startRecording_ios11: " + JSON.stringify(res));
                }, (res) => {
                    //当因为错误或者是可用性更改而停止录制时会调用这个方法 比如:进入后台,再回到前台
                    //如果在录制的过程中,因为一些意外终止了录制,会调用这个方法,可以再此获取错误信息
                    console.log("didStopRecordingWithError: " + JSON.stringify(res));
                }, (res) => {
                    //用来监听 ReplayKit 是否可用的,如果状态发生变化(比如录制过程中,切入设置,关闭权限。)会回调该方法。
                    console.log("screenRecorderDidChangeAvailability: " + JSON.stringify(res));
                });
            },
            stopRecording_ios11() {
                KJScreenRecorder.stopRecording_ios11((res) => {
                    console.log("stopRecording_ios11: " + JSON.stringify(res));
                });
            },
        }
    }
</script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

麦克风权限、相册-写、相册-读

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问