是否支持通过WebView跑H5 WebRTC进行音视频通话?

是否支持通过WebView跑H5 WebRTC进行音视频通话?

HarmonyOS
2024-06-05 21:43:41
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
jmzgh

代码示例如下:

import picker from '@ohos.file.picker'; 
import { BusinessError } from '@ohos.base'; 
import common from '@ohos.app.ability.common'; 
import web_webview from '@ohos.web.webview'; 
class pickImage { 
  constructor() {} 
  testPickImage(): string { 
    let PhotoSelectOptions = new picker.PhotoSelectOptions(); 
    PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; 
    PhotoSelectOptions.maxSelectNumber = 5; 
    let photoPicker = new picker.PhotoViewPicker(); 
    photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult: picker.PhotoSelectResult) => { 
      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult)); 
    }).catch((err: BusinessError) => { 
      console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err)); 
    }); 
    return '121'; 
  } 
} 
class cameraImage { 
  constructor() {} 
  testCameraImage(): string { 
    const context = getContext(this) as common.UIAbilityContext 
    context.startAbilityForResult({ 
      action:'ohos.want.action.imageCapture', 
      parameters:{ 
        callBundleName:'com.hm.imageshow' } 
    },(err,data) => { 
      console.info('imageCapture:' + `${JSON.stringify(data) 
      }`) 
    }) 
    return '1221'; 
  } 
} 
@Entry 
@Component 
struct photo { 
  controller: web_webview.WebviewController = new web_webview.WebviewController(); 
  @State webPickImage: pickImage = new pickImage(); 
  @State webCameraImage: cameraImage = new cameraImage(); 
  build() { 
    Column() { 
      Web({ src: 'https://www.bchrt.com/tools/webcam-test/', controller: this.controller }) 
        .javaScriptAccess(true) 
        .domStorageAccess(true) 
        .onControllerAttached(()=>{ 
        this.controller.registerJavaScriptProxy(this.webPickImage, 'pickImageName', ['testPickImage']); 
        this.controller.registerJavaScriptProxy(this.webCameraImage, 'cameraImageName', ['testCameraImage']); 
        this.controller.refresh(); 
        }) 
    } 
  } 
}
<!DOCTYPE html> 
<html> 
<body> 
<button type="button" onclick="pickImage()">唤起图库</button> 
<button type="button" onclick="cameraImage()">唤起照相机</button> 
<p id="demo"></p> 
<script> 
     function pickImage() { let str=pickImageName.testPickImage(); } function cameraImage(){ let str2=cameraImageName.testCameraImage(); }  
</script> 
</body> 
</html>
分享
微博
QQ
微信
回复
2024-06-06 22:10:11
相关问题
音视频支持哪些编码格式
805浏览 • 1回复 待解决
用ETS实现语音视频通话,应该怎么做?
3245浏览 • 1回复 待解决
webview加载Vue h5失败
17814浏览 • 5回复 待解决
HarmonyOS webview h5的localstorage
417浏览 • 1回复 待解决
HarmonyOS webview 怎么和H5交互
58浏览 • 1回复 待解决
Web中webviewH5交互
1099浏览 • 1回复 待解决
HarmonyOS 音视频操作API
28浏览 • 1回复 待解决
音视频播放是否需要创建长时任务
1871浏览 • 1回复 待解决
HarmonyOS 音视频弹窗demo
35浏览 • 1回复 待解决
HarmonyOS web通过loadData加载h5标签
244浏览 • 1回复 待解决
h5如何在鸿蒙设备进行调试
1860浏览 • 1回复 待解决
如何在webview中使用H5中的alert
1563浏览 • 1回复 待解决
HarmonyOS 是否支持webrtc
403浏览 • 1回复 待解决
鸿蒙音视频通信系统如何实现
4872浏览 • 1回复 待解决