admin管理员组文章数量:1321240
I am trying to build a web app that could capture the user's desktop. I found this web api that should do the job perfectly, but I can't seem to make it work. Right now it should be supported both on the latest version of Edge and on Chrome 70 through enabling a flag, but on both browsers if I am looking at the navigator object the getDisplayMedia()
function is not in there. I also tried calling the function, but I get an error saying that it is not a function(which confirms that it is actually not in the navigator). What could be the problem?
Thanks in advance!
edit: Here is my javascript
function na() {
navigator.mediaDevices.getDisplayMedia({
video: {
mandatory: {
chromeMediaSource: 'desktop',
minWidth: 1280,
maxWidth: 1280,
minHeight: 720,
maxHeight: 720
}
}
}).then((stream)=>console.log(stream))
console.log(navigator)
}
na();
I am trying to build a web app that could capture the user's desktop. I found this web api that should do the job perfectly, but I can't seem to make it work. Right now it should be supported both on the latest version of Edge and on Chrome 70 through enabling a flag, but on both browsers if I am looking at the navigator object the getDisplayMedia()
function is not in there. I also tried calling the function, but I get an error saying that it is not a function(which confirms that it is actually not in the navigator). What could be the problem?
Thanks in advance!
edit: Here is my javascript
function na() {
navigator.mediaDevices.getDisplayMedia({
video: {
mandatory: {
chromeMediaSource: 'desktop',
minWidth: 1280,
maxWidth: 1280,
minHeight: 720,
maxHeight: 720
}
}
}).then((stream)=>console.log(stream))
console.log(navigator)
}
na();
Share
Improve this question
edited Dec 24, 2018 at 14:37
jib
42.5k17 gold badges108 silver badges165 bronze badges
asked Nov 24, 2018 at 22:52
Adrian PascuAdrian Pascu
1,0397 gold badges25 silver badges54 bronze badges
7
- Hard to tell if you don't share any code. – Jim B. Commented Nov 24, 2018 at 23:08
- Ok, I've posted my code. Is just some example code I tried to use – Adrian Pascu Commented Nov 24, 2018 at 23:19
- 1 Odd, not finding anything about the flag to turn it on. What's it supposed to be? – Jim B. Commented Nov 24, 2018 at 23:39
- I read somewhere that by enabling this flag: #enable-experimental-web-platform-features I can use the api on chrome,but it didn't change anything – Adrian Pascu Commented Nov 24, 2018 at 23:42
- I can't find where this is supported by chrome yet. You're a trailblazer, I think. – Jim B. Commented Nov 24, 2018 at 23:44
1 Answer
Reset to default 6While not available yet, getDisplayMedia can be polyfilled. This is described in this blog post. In Chrome this requires an extension so if you start to develop just now it might be better to wait until getDisplayMedia is available in Chrome (it should be in Chrome Canary without flags soon)
Note that you are mixing old constraints (which were required to get desktop sharing from navigator.mediaDevices.getUserMedia in Chrome) with navigator.mediaDevices.getDisplayMedia which is not going to work.
本文标签: javascriptnavigatormediaDevicesgetDisplayMedia not supportedStack Overflow
版权声明:本文标题:javascript - navigator.mediaDevices.getDisplayMedia not supported - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742097962a2420666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论