qt c++ Linux QWEBVIEW视频贴
我尝试在我的QWBView QT项目中制作Navigator.Mediadevices.getusermedia。在HTML中,我使用的标准代码正常:
<style>
#container {
margin: 0px auto;
width: 500px;
height: 375px;
border: 10px #333 solid;
}
#videoElement {
width: 500px;
height: 375px;
background-color: #666;
}
</style>
<div id="container">
<video autoplay="true" id="videoElement">
</video>
</div>
<script>
var video = document.querySelector("#videoElement");
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true })
.then(function (stream) {
video.srcObject = stream;
})
.catch(function (err0r) {
console.log("Something went wrong!");
});
}
</script>
当我在浏览器中打开它时,它可以访问网络摄像头并显示视频。但是,当我在QT中运行时,我会在控制台中出现错误:
TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.getUserMedia')
请帮助:如何在qwebview中设置视频访问?谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您必须要求使用 权限之一 以使用 video&amp;音频
检查此 qwebenginepage :: permission-polight-prolicypolicy 以获取更多信息。
I think you have to request one of the permissions to use video & audio
Check this QWebEnginePage::Feature & this QWebEnginePage::PermissionPolicy for more information.