我正在尝试访问AngularJs控制器中的javasctipt mediaDevices --这是我的控制器代码:
(function () {
'use strict';
angular.module('app')
.controller('AssistenzaCtrl', ['$scope', 'largeTabController', 'readSelect', '$mdDialog', '$interval', '$http', '$window', AssistenzaCtrl])
function AssistenzaCtrl($scope, largeTabController, readSelect, $mdDialog, $interval, $http, $window ) {
$scope.init = function () {
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
console.log("enumerateDevices() not supported.");
}
navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
devices.forEach(function(device) {
console.log(device.kind + ": " + device.label +
" id = " + device.deviceId);
});
})
.catch(function(err) {
console.log(err.name + ": " + err.message);
});
}
}
})(); 如果我用F12工具测试我的控制器,navigator.mediaDevices是未定义的,但我的浏览器支持mediaDevices,因为如果我在没有AngularJs的独立页面中运行相同的代码,我可以成功地枚举我的设备。
AngularJs和getUserMedia()之间是否存在兼容性问题?
发布于 2020-04-26 23:13:17
这个问题与使用http协议而不是od https有关。浏览器仅为https或本地主机连接启用getUserMedia。
我希望这个答案能对某人有所帮助。
https://stackoverflow.com/questions/61447502
复制相似问题