是否支持通过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>
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
分享
微博
QQ
微信
回复
2024-06-06 22:10:11


相关问题
HarmonyOS 网路音视频通话后台保活
478浏览 • 1回复 待解决
用ETS实现语音视频通话,应该怎么做?
3631浏览 • 1回复 待解决
音视频支持哪些编码格式
1416浏览 • 1回复 待解决
HarmonyOS webview是否支持webrtc
409浏览 • 1回复 待解决
HarmonyOS 通过webview改变H5页面字体
591浏览 • 1回复 待解决
HarmonyOS 音视频操作API
605浏览 • 1回复 待解决
HarmonyOS 音视频相关问题
634浏览 • 1回复 待解决
HarmonyOS 音视频弹窗demo
654浏览 • 1回复 待解决
音视频播放是否需要创建长时任务
2414浏览 • 1回复 待解决
HarmonyOS webview h5的localstorage
789浏览 • 1回复 待解决
webview加载Vue h5失败
18357浏览 • 5回复 待解决
HarmonyOS WebView加载H5卡顿
625浏览 • 1回复 待解决