- 调用 xr-scene.share.recordStart() 失败?
[图片] // 开始录制 recordStart: async function() { console.log("share.recordState="+this.scene.share.recordState); const xrFrameSystem = wx.getXrFrameSystem(); if (this.scene.share.recordState === xrFrameSystem.EShareRecordState.Recording) { console.log("正在录制"); return; } //录制参数 const options: XrFrame.IShareRecordOptions = { fps: 30, width: this.scene.width, height: this.scene.height, videoBitsPerSecond: 1000 }; //启动录制 const share = this.scene.share; await share.recordStart(options); //这句代码有时会失败。不是必失败。 //录制x秒后自动停止,并保存到相册 this.timeoutID = setTimeout(async function(){ await share.recordFinishToAlbum(options); console.log("record finish"); }, 8000); },
11-11 - GamaRecorder.share:fail no recorded video
{errMsg: "operateGameRecorderVideo:fail GamaRecorder.share:fail no recorded video"} [图片] 下面的代码是基于团结引擎开发的。 #region 录制视频 // 开始录制 public void StartRecord() { Debug.Log("StartRecord()"); //需要先申请录制权限 GetSettingOption settingOption = new GetSettingOption(); settingOption.fail += (res) => { Debug.LogError(res.errMsg); }; settingOption.success += (res) => { //用户是否授权了录制 if (res.authSetting.ContainsKey("scope.record") && res.authSetting["scope.record"]) { Debug.Log("有录制权限"); InternalGameRecord(); } else { Debug.LogError("没有录制权限"); AuthorizeOption authorizeOption = new AuthorizeOption(); authorizeOption.scope = "scope.record"; authorizeOption.fail += (res) => { Debug.LogError(res.errMsg); }; authorizeOption.success += (res) => { Debug.Log("用户同意授权-录制"); InternalGameRecord(); }; Debug.Log("向用户申请录制权限"); WX.Authorize(authorizeOption); } }; WX.GetSetting(settingOption); } // 开始游戏录制 private void InternalGameRecord() { Debug.Log("InternalGameRecord()"); WXGameRecorder recorder = WXBase.GetGameRecorder(); recorder.On("error", (res) => { Debug.LogFormat("record error: code={0}, message={1}", res.code, res.message); }); recorder.On("start", (res) => { Debug.Log("record start"); if (res.code != 0) { Debug.LogErrorFormat("start error: code={0}, message={1}", res.code, res.message); } }); recorder.On("stop", (res) => { Debug.Log("record stop"); if (res.code != 0) { Debug.LogErrorFormat("stop error: code={0}, message={1}", res.code, res.message); } //移除所有监听事件 recorder.Off("error"); recorder.Off("start"); recorder.Off("timeUpdate"); recorder.Off("stop"); }); recorder.On("timeUpdate", (res) => { Debug.Log("record timeUpdate"); if (res.code != 0) { Debug.LogErrorFormat("timeUpdate error: code={0}, message={1}", res.code, res.message); } }); GameRecorderStartOption option = new GameRecorderStartOption(); option.bitrate = 600; option.duration = 10; option.fps = 24; option.gop = 2; option.hookBgm = false; recorder.Start(option); } // 停止录制 public void StopRecord() { Debug.Log("StopRecord()"); WXGameRecorder recorder = WXBase.GetGameRecorder(); recorder.Stop(); OperateGameRecorderVideoOption option = new OperateGameRecorderVideoOption(); option.atempo = 1; option.title = "XXXXXXXXX"; double[][] timeRange = new double[1][]; timeRange[0][0] = 1000; timeRange[0][1] = 3000; option.timeRange = timeRange; //调用此接口报错: //{errMsg: "operateGameRecorderVideo:fail GamaRecorder.share:fail no recorded video"} WX.OperateGameRecorderVideo(option); } #endregion
11-07