更新记录

1.0.4(2022-01-21)

修复Android端加入房间时,没有申请权限的Bug

1.0.3(2022-01-15)

1.修复ios版本引用插件后打包失败问题; 2.去除ios包中多余的TXLiteAVSDK_TRTC.a文件;

1.0.2(2022-01-12)

新增ios端视频听话功能

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:5.0 - 11.0 armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 适用版本区间:9 - 15

原生插件通用使用流程:

  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原生插件配置”->”云端插件“列表中删除该插件重新选择


使用说明

1.本插件基于腾讯实时音视频封装,接口调用和返回参数和腾讯保持一致
2.使用本插件,需要单独购买腾讯实时音视频服务

只能在nvue页面中使用自定义组件,目前已满足基本的视频通话

<template>
    <div>
        <div class="btn-group">
            <button class="my-button" @click="joinPersionVideo">加入房间1</button>
            <button class="my-button" @click="exitPersionVideo">退出房间</button>
            <button class="my-button" @click="joinPersionVideo2">加入房间2</button>
        </div>
        <div class="btn-group">
            <button class="my-button" @click="addListener">添加事件</button>
            <button class="my-button" @click="removeListener">移除事件</button>
        </div>
        <div class="video-group">
            <excbyte-trtc-video class="video-item" userId="807512"></excbyte-trtc-video>
            <excbyte-trtc-video class="video-item" userId="1234"></excbyte-trtc-video>
        </div>

    </div>
</template>

<script>
    import ExcbyteTrtc from '../../common/ExcbyteTrtc.js'
    export default {
        data() {
            return {

            }
        },
        onLoad() {
            this.initTrtc()
        },
        methods: {
            initTrtc() {
                ExcbyteTrtc.sharedInstance();
                ExcbyteTrtc.addListener("onUserVideoAvailable", function(param) { //注册远程用户视频开启监听
                    console.log("onUserVideoAvailable==" + JSON.stringify(param));
                    uni.showToast({
                        title: JSON.stringify(param),
                        icon: 'none'
                    })
                    ExcbyteTrtc.startRemoteView(param.userId);
                });
                ExcbyteTrtc.addListener("onError", function(param) { //注册错误监听监听

                    uni.showToast({
                        title: JSON.stringify(param),
                        icon: 'none'
                    })
                });
            },
            async joinPersionVideo() {
                let userSig = ExcbyteTrtc.creatUserSig(1400390306,
                    "451ad5bd80bc9560c63461b316c2f9ba0fd6f273070461ae5e2afeabdf3da719", "1234");
                ExcbyteTrtc.enterRoom({
                    sdkAppId: 1400390306,
                    userId: "1234",
                    userSig: userSig,
                    roomId: 17509,
                    role: 20
                }, ExcbyteTrtc.TRTC_APP_SCENE_VIDEOCALL);
                ExcbyteTrtc.startLocalPreview(true); //开启视频
                ExcbyteTrtc.enableAudioVolumeEvaluation(300);
                ExcbyteTrtc.startLocalAudio(); //开启本地语音
                ExcbyteTrtc.enableScreenOn(); //屏幕常亮

                ExcbyteTrtc.startPlayCall(); //呼叫声音
            },
            async joinPersionVideo2() {
                let userSig = ExcbyteTrtc.creatUserSig(1400390306,
                    "451ad5bd80bc9560c63461b116c2f9ba0fd6f273070461ae5e2afeabdf3da719", "807512");
                ExcbyteTrtc.enterRoom({
                    sdkAppId: 1400390306,
                    userId: "807512",
                    userSig: userSig,
                    roomId: 17509,
                    role: 20
                }, ExcbyteTrtc.TRTC_APP_SCENE_VIDEOCALL);
                ExcbyteTrtc.startLocalPreview(true); //开启视频
                ExcbyteTrtc.enableAudioVolumeEvaluation(300);
                ExcbyteTrtc.startLocalAudio(); //开启本地语音
                ExcbyteTrtc.enableScreenOn(); //屏幕常亮

            },

            async exitPersionVideo() {

                ExcbyteTrtc.stopPlayCall(); //呼叫声音
                ExcbyteTrtc.destroySharedInstance();
            },
            removeListener() {
                ExcbyteTrtc.removeListener("onNetworkQuality")
            },
            addListener(){
                ExcbyteTrtc.addListener("onNetworkQuality",(params)=>{
                    uni.showToast({
                        title:JSON.stringify(params),
                        icon:'none'
                    })
                })
            }
        }
    }
</script>

<style>
    .video-group {
        flex-direction: row;
    }

    .video-item {
        flex: 1;
        height: 200px;
        background: #ff0000;
        margin: 10px;
    }

    .btn-group {
        flex-direction: row;
    }

    .my-button {
        margin: 10px;
        background: #00ff00;
        text-align: center;
        width: 200px;
        height: 40px;
    }
</style>

所有接口和常量(ExcbyteTrtc.js),具体含义参考腾讯实时音视频文档

var ExcbyteTrtc = uni.requireNativePlugin("excbyte-trtc");

export default {
    creatUserSig(sdkAppId, secretKey, userId) {
        return ExcbyteTrtc.creatUserSig(sdkAppId, secretKey, userId)
    },

    enableScreenOn() {//保持屏幕常亮
        ExcbyteTrtc.enableScreenOn()
    },
    disableScreenOn() {//关闭屏幕常亮
        ExcbyteTrtc.disableScreenOn()
    },
    sharedInstance() {
        return ExcbyteTrtc.sharedInstance()
    },
    destroySharedInstance() {
        ExcbyteTrtc.destroySharedInstance()
    },

    enterRoom(data, scene) {
        data.privateMapKey = data.privateMapKey || "";
        data.businessInfo = data.businessInfo || "";
        ExcbyteTrtc.enterRoom(data, scene)
    },
    exitRoom() {
        ExcbyteTrtc.exitRoom()
    },
    switchRole(role) {
        ExcbyteTrtc.switchRole(role)
    },
    connectOtherRoom(param) {
        ExcbyteTrtc.connectOtherRoom(param)
    },

    disconnectOtherRoom() {
        ExcbyteTrtc.disconnectOtherRoom()
    },

    setDefaultStreamRecvMode(autoRecvAudio, autoRecvVideo) {
        ExcbyteTrtc.setDefaultStreamRecvMode(autoRecvAudio, autoRecvVideo)
    },

    startPublishing(streamId, streamType) {
        ExcbyteTrtc.startPublishing(streamId, streamType)
    },

    stopPublishing() {
        ExcbyteTrtc.stopPublishing()
    },

    startPublishCDNStream(param) {
        ExcbyteTrtc.startPublishCDNStream(param)
    },

    stopPublishCDNStream() {
        ExcbyteTrtc.stopPublishCDNStream()
    },

    setMixTranscodingConfig(config) {
        ExcbyteTrtc.setMixTranscodingConfig(config)
    },

    startLocalPreview(frontCamera) {
        ExcbyteTrtc.startLocalPreview(frontCamera)
    },
    stopLocalPreview() {
        ExcbyteTrtc.stopLocalPreview()
    },

    muteLocalVideo(mute) {
        ExcbyteTrtc.muteLocalVideo(mute)
    },

    startRemoteView(userId) {
        ExcbyteTrtc.startRemoteView(userId)
    },

    stopRemoteView(userId) {
        ExcbyteTrtc.stopRemoteView(userId)
    },

    stopAllRemoteView() {
        ExcbyteTrtc.stopAllRemoteView()
    },

    muteRemoteVideoStream(userId, mute) {
        ExcbyteTrtc.muteRemoteVideoStream(userId, mute)
    },

    muteAllRemoteVideoStreams(mute) {
        ExcbyteTrtc.muteAllRemoteVideoStreams(mute)
    },

    setVideoEncoderParam(data) {
        ExcbyteTrtc.setVideoEncoderParam(data)
    },
    setNetworkQosParam(data) {
        ExcbyteTrtc.setNetworkQosParam(data)
    },

    setLocalViewFillMode(mode) {
        ExcbyteTrtc.setLocalViewFillMode(mode)
    },

    setRemoteViewFillMode(userId, mode) {
        ExcbyteTrtc.setRemoteViewFillMode(userId, mode)
    },

    setLocalViewRotation(rotation) {
        ExcbyteTrtc.setLocalViewRotation(rotation)
    },

    setRemoteViewRotation(userId, rotation) {
        ExcbyteTrtc.setRemoteViewRotation(userId, rotation)
    },

    setVideoEncoderRotation(rotation) {
        ExcbyteTrtc.setVideoEncoderRotation(rotation)
    },

    setLocalViewMirror(mirrorType) {
        ExcbyteTrtc.setLocalViewMirror(mirrorType)
    },

    setVideoEncoderMirror(mirror) {
        ExcbyteTrtc.setVideoEncoderMirror(mirror)
    },

    setGSensorMode(mode) {
        ExcbyteTrtc.setGSensorMode(mode)
    },

    enableEncSmallVideoStream(enable, smallVideoEncParam) {
        return ExcbyteTrtc.enableEncSmallVideoStream(enable, smallVideoEncParam)
    },

    setRemoteVideoStreamType(userId, streamType) {
        return ExcbyteTrtc.setRemoteVideoStreamType(userId, streamType)
    },

    setPriorRemoteVideoStreamType(streamType) {
        return ExcbyteTrtc.setPriorRemoteVideoStreamType(streamType)
    },

    snapshotVideo(userId, streamType) {
        return ExcbyteTrtc.snapshotVideo(userId, streamType)
    },

    startLocalAudio() {
        ExcbyteTrtc.startLocalAudio()
    },
    stopLocalAudio() {
        ExcbyteTrtc.stopLocalAudio()
    },

    muteLocalAudio(mute) {
        ExcbyteTrtc.muteLocalAudio(mute)
    },
    muteRemoteAudio(userId, mute) {
        ExcbyteTrtc.muteRemoteAudio(userId, mute)
    },
    muteAllRemoteAudio(mute) {
        ExcbyteTrtc.muteAllRemoteAudio(mute)
    },

    setRemoteAudioVolume(userId, volume) {
        ExcbyteTrtc.setRemoteAudioVolume(userId, volume)
    },

    setAudioCaptureVolume(volume) {
        ExcbyteTrtc.setAudioCaptureVolume(volume)
    },

    getAudioCaptureVolume() {
        return ExcbyteTrtc.getAudioCaptureVolume()
    },

    setAudioPlayoutVolume(volume) {
        ExcbyteTrtc.setAudioPlayoutVolume(volume)
    },

    getAudioPlayoutVolume() {
        return ExcbyteTrtc.getAudioPlayoutVolume()
    },

    enableAudioVolumeEvaluation(intervalMs) {
        ExcbyteTrtc.enableAudioVolumeEvaluation(intervalMs)
    },

    startAudioRecording(param) {
        return ExcbyteTrtc.startAudioRecording(param)
    },

    stopAudioRecording() {
        ExcbyteTrtc.stopAudioRecording()
    },

    setSystemVolumeType(type) {
        ExcbyteTrtc.setSystemVolumeType(type)
    },

    enableAudioEarMonitoring(enable) {
        ExcbyteTrtc.enableAudioEarMonitoring(enable)
    },

    switchCamera() {
        ExcbyteTrtc.switchCamera()
    },
    isCameraZoomSupported() {
        return ExcbyteTrtc.isCameraZoomSupported()
    },

    setZoom(distance) {
        ExcbyteTrtc.setZoom(distance)
    },

    isCameraTorchSupported() {
        return ExcbyteTrtc.isCameraTorchSupported()
    },

    enableTorch(enable) {
        return ExcbyteTrtc.enableTorch(enable)
    },

    isCameraFocusPositionInPreviewSupported() {
        return ExcbyteTrtc.isCameraFocusPositionInPreviewSupported()
    },

    setFocusPosition(x, y) {
        ExcbyteTrtc.setFocusPosition(x, y)
    },

    isCameraAutoFocusFaceModeSupported() {
        return ExcbyteTrtc.isCameraAutoFocusFaceModeSupported()
    },

    startScreenRecord() {
        ExcbyteTrtc.startScreenRecord()
    },
    stopScreenRecord() {
        ExcbyteTrtc.stopScreenRecord()
    },

    startPlayCall() {
        return  ExcbyteTrtc.startPlayCall()
    },
    stopPlayCall() {
        return  ExcbyteTrtc.stopPlayCall()
    },
    /*
     * setAudioRoute
     * int  0 Speaker 1 Earpiece
     */
    setAudioRoute(router) {
        ExcbyteTrtc.setAudioRoute(router)
    },

    addListener(eventName, handler) {
        if (!eventName || !handler) return;
        return plus.globalEvent.addEventListener(eventName, handler)
    },
    removeListener(eventName, handler) {
        if (!eventName) return;
        if (!handler) {
            plus.globalEvent.removeEventListener(eventName)
            return
        }
        plus.globalEvent.removeEventListener(eventName, handler)
    },

    TRTC_VIDEO_RESOLUTION_120_120: 1,
    TRTC_VIDEO_RESOLUTION_160_160: 3,
    TRTC_VIDEO_RESOLUTION_270_270: 5,
    TRTC_VIDEO_RESOLUTION_480_480: 7,
    TRTC_VIDEO_RESOLUTION_160_120: 50,
    TRTC_VIDEO_RESOLUTION_240_180: 52,
    TRTC_VIDEO_RESOLUTION_280_210: 54,
    TRTC_VIDEO_RESOLUTION_320_240: 56,
    TRTC_VIDEO_RESOLUTION_400_300: 58,
    TRTC_VIDEO_RESOLUTION_480_360: 60,
    TRTC_VIDEO_RESOLUTION_640_480: 62,
    TRTC_VIDEO_RESOLUTION_960_720: 64,
    TRTC_VIDEO_RESOLUTION_160_90: 100,
    TRTC_VIDEO_RESOLUTION_256_144: 102,
    TRTC_VIDEO_RESOLUTION_320_180: 104,
    TRTC_VIDEO_RESOLUTION_480_270: 106,
    TRTC_VIDEO_RESOLUTION_640_360: 108,
    TRTC_VIDEO_RESOLUTION_960_540: 110,
    TRTC_VIDEO_RESOLUTION_1280_720: 112,
    TRTC_VIDEO_RESOLUTION_MODE_LANDSCAPE: 0,
    TRTC_VIDEO_RESOLUTION_MODE_PORTRAIT: 1,
    TRTC_VIDEO_STREAM_TYPE_BIG: 0,
    TRTC_VIDEO_STREAM_TYPE_SMALL: 1,
    TRTC_VIDEO_STREAM_TYPE_SUB: 2,
    TRTC_QUALITY_UNKNOWN: 0,
    TRTC_QUALITY_Excellent: 1,
    TRTC_QUALITY_Good: 2,
    TRTC_QUALITY_Poor: 3,
    TRTC_QUALITY_Bad: 4,
    TRTC_QUALITY_Vbad: 5,
    TRTC_QUALITY_Down: 6,
    TRTC_VIDEO_RENDER_MODE_FILL: 0,
    TRTC_VIDEO_RENDER_MODE_FIT: 1,
    TRTC_VIDEO_ROTATION_0: 0,
    TRTC_VIDEO_ROTATION_90: 1,
    TRTC_VIDEO_ROTATION_180: 2,
    TRTC_VIDEO_ROTATION_270: 3,
    TRTC_BEAUTY_STYLE_SMOOTH: 0,
    TRTC_BEAUTY_STYLE_NATURE: 1,
    TRTC_VIDEO_PIXEL_FORMAT_UNKNOWN: 0,
    TRTC_VIDEO_PIXEL_FORMAT_I420: 1,
    TRTC_VIDEO_PIXEL_FORMAT_Texture_2D: 2,
    TRTC_VIDEO_PIXEL_FORMAT_TEXTURE_EXTERNAL_OES: 3,
    TRTC_VIDEO_PIXEL_FORMAT_NV21: 4,
    TRTC_VIDEO_MIRROR_TYPE_AUTO: 0,
    TRTC_VIDEO_MIRROR_TYPE_ENABLE: 1,
    TRTC_VIDEO_MIRROR_TYPE_DISABLE: 2,
    TRTC_VIDEO_BUFFER_TYPE_UNKNOWN: 0,
    TRTC_VIDEO_BUFFER_TYPE_BYTE_BUFFER: 1,
    TRTC_VIDEO_BUFFER_TYPE_BYTE_ARRAY: 2,
    TRTC_VIDEO_BUFFER_TYPE_TEXTURE: 3,
    TRTC_APP_SCENE_VIDEOCALL: 0,
    TRTC_APP_SCENE_LIVE: 1,
    TRTC_APP_SCENE_AUDIOCALL: 2,
    TRTC_APP_SCENE_VOICE_CHATROOM: 3,
    TRTCRoleAnchor: 20,
    TRTCRoleAudience: 21,
    VIDEO_QOS_CONTROL_CLIENT: 0,
    VIDEO_QOS_CONTROL_SERVER: 1,
    TRTC_VIDEO_QOS_PREFERENCE_SMOOTH: 1,
    TRTC_VIDEO_QOS_PREFERENCE_CLEAR: 2,
    TRTCAudioSampleRate16000: 16000,
    TRTCAudioSampleRate32000: 32000,
    TRTCAudioSampleRate44100: 44100,
    TRTCAudioSampleRate48000: 48000,
    TRTC_AUDIO_ROUTE_SPEAKER: 0,
    TRTC_AUDIO_ROUTE_EARPIECE: 1,
    TRTC_REVERB_TYPE_0: 0,
    TRTC_REVERB_TYPE_1: 1,
    TRTC_REVERB_TYPE_2: 2,
    TRTC_REVERB_TYPE_3: 3,
    TRTC_REVERB_TYPE_4: 4,
    TRTC_REVERB_TYPE_5: 5,
    TRTC_REVERB_TYPE_6: 6,
    TRTC_REVERB_TYPE_7: 7,
    TRTC_VOICE_CHANGER_TYPE_0: 0,
    TRTC_VOICE_CHANGER_TYPE_1: 1,
    TRTC_VOICE_CHANGER_TYPE_2: 2,
    TRTC_VOICE_CHANGER_TYPE_3: 3,
    TRTC_VOICE_CHANGER_TYPE_4: 4,
    TRTC_VOICE_CHANGER_TYPE_5: 5,
    TRTC_VOICE_CHANGER_TYPE_6: 6,
    TRTC_VOICE_CHANGER_TYPE_7: 7,
    TRTC_VOICE_CHANGER_TYPE_8: 8,
    TRTC_VOICE_CHANGER_TYPE_9: 9,
    TRTC_VOICE_CHANGER_TYPE_10: 10,
    TRTC_VOICE_CHANGER_TYPE_11: 11,
    TRTC_AUDIO_FRAME_FORMAT_PCM: 1,
    TRTCSystemVolumeTypeAuto: 0,
    TRTCSystemVolumeTypeMedia: 1,
    TRTCSystemVolumeTypeVOIP: 2,
    TRTC_DEBUG_VIEW_LEVEL_GONE: 0,
    TRTC_DEBUG_VIEW_LEVEL_STATUS: 1,
    TRTC_DEBUG_VIEW_LEVEL_ALL: 2,
    TRTC_LOG_LEVEL_VERBOSE: 0,
    TRTC_LOG_LEVEL_DEBUG: 1,
    TRTC_LOG_LEVEL_INFO: 2,
    TRTC_LOG_LEVEL_WARN: 3,
    TRTC_LOG_LEVEL_ERROR: 4,
    TRTC_LOG_LEVEL_FATAL: 5,
    TRTC_LOG_LEVEL_NULL: 6,
    TRTC_GSENSOR_MODE_DISABLE: 0,
    TRTC_GSENSOR_MODE_UIAUTOLAYOUT: 1,
    TRTC_GSENSOR_MODE_UIFIXLAYOUT: 2,
    TRTC_TranscodingConfigMode_Unknown: 0,
    TRTC_TranscodingConfigMode_Manual: 1,
};

隐私、权限声明

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

摄像头、麦克风

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

插件自身不采集任何数据,插件使用了腾讯云的sdk采集数据。说明参考官方https://cloud.tencent.com/product/trtc

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

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