收藏
回答

游戏回放录制完成,调用wx.operateGameRecorderVideo,为何没有唤起分享功能?

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小游戏 Bug wx.operateGameRecorderVideo 微信安卓客户端 8.0.35 2.32.0
https://developers.weixin.qq.com/minigame/dev/api/game-recorder/wx.operateGameRecorderVideo.html

// 结束录制方法
public static endGameRecorder() {
        if (!this.SUPPORT || !this.checkVersion()) {
            return;
        }
            const recorder = window['wx'].getGameRecorder();
            recorder.on('stop', (res) => {
                console.log(`对局回放时长: ${res.duration}`);
                this.shareGameRecorder();
            });
            recorder.stop();             
            console.log("结束录制-游戏分享视频");
    }

// 分享录像方法
public static shareGameRecorder() {
        if (!this.SUPPORT || !this.checkVersion()) {
            return;
        }
            console.log("分享游戏视频");
            window['wx'].operateGameRecorderVideo({
                'title': '试试看',
                'desc': '试试看',
                'query': 'a=1&b=2',
                // 'path': '',
                // 'bgm': null,
                'timeRange': [[0, 3000]],
                // 'volume': 0,
                // 'atempo': 2,
                // 'audioMix': false
            });
            console.log("分享游戏视频");
    }

static checkVersion(): boolean {
            const version = window['wx'].getAppBaseInfo().SDKVersion
            if (this.compareVersion(version, '2.26.1') >= 0) {
                return true;
            }

        console.log('版本过低,不支持');
        return false;
    }


    /**
     * 对比两个版本号
     * @param v1 
     * @param v2 
     * @returns 返回0或1,表示v1等于或高于v2
     */
    static compareVersion(v1, v2) {
        v1 = v1.split('.')
        v2 = v2.split('.')
        const len = Math.max(v1.length, v2.length)


        while (v1.length < len) {
            v1.push('0')
        }
        while (v2.length < len) {
            v2.push('0')
        }


        for (let i = 0; i < len; i++) {
            const num1 = parseInt(v1[i])
            const num2 = parseInt(v2[i])


            if (num1 > num2) {
                return 1
            } else if (num1 < num2) {
                return -1
            }
        }
        return 0;
    }


调用分享以后,console.log里面的内容都按顺序正常输出,但是没有唤出分享界面。

使用wx.createGameRecorderShareButton,可以正常唤起。

回答关注问题邀请回答
收藏

1 个回答

  • 丁伟
    丁伟
    2023-07-07

    经过我的尝试,这个API必须在touchend事件中调用,真是垃圾啊,文档上也没标明,浪费了我好多时间,而且这个API参数也是支持配置success、fail这种回调的,文档中也没写,垃圾

    2023-07-07
    有用
    回复
登录 后发表内容