admin管理员组文章数量:1406921
I used simpl.info code as example. On their example I can see "TOSHIBA Web Camera - HD (13d3:5606)" in the "Video source" Select. Hence they can retrieve the label property of the sources. I can get the sources easily but the label is empty:
SourceInfo {facing: "", label: "", kind: "video", id: "0c2c5a2bf359a3ced6d7d39efe2f40477f50d5627df618a6f1998b5142437b27"}
Here is my code:
$(document).ready(function ()
{
if (navigator.getUserMedia)
{
if (typeof MediaStreamTrack.getSources !== 'undefined')
{
MediaStreamTrack.getSources(gotSources);
}
}
});
function gotSources(sourceInfos)
{
for (var i = 0; i < sourceInfos.length; i++)
{
var sourceInfo = sourceInfos[i];
if (sourceInfo.kind == 'video')
{
console.log(sourceInfo);
}
}
}
I used simpl.info code as example. On their example I can see "TOSHIBA Web Camera - HD (13d3:5606)" in the "Video source" Select. Hence they can retrieve the label property of the sources. I can get the sources easily but the label is empty:
SourceInfo {facing: "", label: "", kind: "video", id: "0c2c5a2bf359a3ced6d7d39efe2f40477f50d5627df618a6f1998b5142437b27"}
Here is my code:
$(document).ready(function ()
{
if (navigator.getUserMedia)
{
if (typeof MediaStreamTrack.getSources !== 'undefined')
{
MediaStreamTrack.getSources(gotSources);
}
}
});
function gotSources(sourceInfos)
{
for (var i = 0; i < sourceInfos.length; i++)
{
var sourceInfo = sourceInfos[i];
if (sourceInfo.kind == 'video')
{
console.log(sourceInfo);
}
}
}
Share
Improve this question
edited Dec 17, 2014 at 11:21
Arthur Rey
asked Dec 10, 2014 at 18:44
Arthur ReyArthur Rey
3,0443 gold badges24 silver badges49 bronze badges
1
- I bump into this too. In the documentation it is stated the label is empty if the user has not approved permissions to use his/hers camera / microphone, but for me the problem persist even if I have permissions. Can you try querying for the sources after you've been granted permission? – Lawliet Commented Dec 17, 2014 at 11:03
1 Answer
Reset to default 5As stated in answer #4, the user must have already granted permission to the page to use the media devices in order to get the label
populated. When served over HTTPS, the browser will remember permission granted on subsequent loads, so the permission will have been granted before requesting media. When using HTTP, not HTTPS, the getUserMedia request must be made and accepted before MediaStreamTrack.getSources
will populate labels.
I tried simpl.info on another puter and as expected the label
was empty the first time, and populated after the second time.
本文标签: javascriptChrome MediaStreamTrackgetSources() returns sources with empty labelStack Overflow
版权声明:本文标题:javascript - Chrome MediaStreamTrack.getSources() returns sources with empty label - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744974684a2635446.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论