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密钥对转换失败
444浏览 • 1回复 待解决
huks sm2签名验签失败
89浏览 • 1回复 待解决
OpenHarmony-2.2-Beta2 编译失败,求助
8651浏览 • 1回复 已解决
HarmonyOS下载文件失败返回
343浏览 • 1回复 待解决
Hi3861 “cmsis_os2.h”查找失败
4318浏览 • 1回复 已解决
startAbility跳转失败返回错误码16000001
1951浏览 • 1回复 待解决
OH _Audio播放音频问题
2013浏览 • 1回复 待解决
OH_ImageNative转为cv::Mat
222浏览 • 1回复 待解决