OH_AVScreenCapture_StartScreenRecording返回失败2

OH_AVScreenCapture_StartScreenRecording接口调用失败,返回失败2;AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT = AV_SCREEN_CAPTURE_ERR_BASE + 2

HarmonyOS
2024-09-10 11:46:20
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Heiang

走老通路就要capturescreen的权限 走新通路就要设置回调 然后会弹出隐私弹窗,录屏取码流有新的文档,可以参考录屏取码流:https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/media/using-avscreencapture-for-buffer.md

// 开始录屏原始码流 
static napi_value StartScreenCapture_01(napi_env env, napi_callback_info info) { 
  g_avCapture = OH_AVScreenCapture_Create(); 
  if (g_avCapture == nullptr) { 
    OH_LOG_ERROR(LOG_APP, "create screen capture failed"); 
  } 
  OH_AVScreenCaptureConfig config_; 
  SetConfig(config_); 
  OpenFile("Demo"); 
  bool isMicrophone = true; 
  OH_AVScreenCapture_SetMicrophoneEnabled(g_avCapture, isMicrophone); 
  OH_AVScreenCapture_SetErrorCallback(g_avCapture, OnError, nullptr); 
  OH_AVScreenCapture_SetStateCallback(g_avCapture, OnStateChange, nullptr); 
  OH_AVScreenCapture_SetDataCallback(g_avCapture, OnBufferAvailable, nullptr); 
  int result = OH_AVScreenCapture_Init(g_avCapture, config_); 
  if (result != AV_SCREEN_CAPTURE_ERR_OK) { 
    OH_LOG_INFO(LOG_APP, "==DEMO== ScreenCapture OH_AVScreenCapture_Init failed %{public}d", result); 
  } 
  OH_LOG_INFO(LOG_APP, "==DEMO== ScreenCapture OH_AVScreenCapture_Init %{public}d", result); 
 
  result = OH_AVScreenCapture_StartScreenCapture(g_avCapture); 
  if (result != AV_SCREEN_CAPTURE_ERR_OK) { 
    OH_LOG_INFO(LOG_APP, "==DEMO== ScreenCapture Started failed %{public}d", result); 
    OH_AVScreenCapture_Release(g_avCapture); 
  } 
  OH_LOG_INFO(LOG_APP, "==DEMO== ScreenCapture Started %{public}d", result); 
 
  m_isRunning = true; 
 
  napi_value res; 
  napi_create_int32(env, result, &res); 
  return res; 
}
分享
微博
QQ
微信
回复
2024-09-10 17:31:48
相关问题
HarmonyOS sm2验签失败
38浏览 • 1回复 待解决
HarmonyOS SM2密钥对转换失败
610浏览 • 1回复 待解决
huks sm2签名验签失败
237浏览 • 1回复 待解决
OpenHarmony-2.2-Beta2 编译失败,求助
8764浏览 • 1回复 已解决
HarmonyOS下载文件失败返回
477浏览 • 1回复 待解决
HarmonyOS 安全按钮返回权限失败
50浏览 • 1回复 待解决
HarmonyOS 创建window失败返回1300002
67浏览 • 1回复 待解决
Hi3861 “cmsis_os2.h”查找失败
4464浏览 • 1回复 已解决
startAbility跳转失败返回错误码16000001
2132浏览 • 1回复 待解决
HarmonyOS SM2加签返回Base64字符串
31浏览 • 1回复 待解决