是否支持通过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
相关问题
音视频支持哪些编码格式
192浏览 • 1回复 待解决
webview加载Vue h5失败
16135浏览 • 5回复 待解决
用ETS实现语音视频通话,应该怎么做?
1766浏览 • 1回复 待解决
Web中webviewH5交互
443浏览 • 1回复 待解决
h5如何在鸿蒙设备进行调试
387浏览 • 1回复 待解决
音视频播放是否需要创建长时任务
690浏览 • 1回复 待解决
如何在webview中使用H5中的alert
539浏览 • 1回复 待解决
鸿蒙音视频通信系统如何实现
3493浏览 • 1回复 待解决
av_player新增支持本地音视频文件播放
544浏览 • 1回复 待解决
如何实现H5自定义事件
784浏览 • 1回复 待解决
如何加载字符串形式H5数据
608浏览 • 1回复 待解决
FA里内嵌H5是怎么保持登录状态?
5700浏览 • 1回复 待解决