我正在设置一个原型,在Safari IOS11中为Iphone使用Opentok Webrtc。这一切都很好,直到今天(我不记得改变任何东西)。我收到的错误是
OT.Publisher访问被拒绝:权限被拒绝:最终用户拒绝硬件设备的权限(getUserMedia错误: NotAllowedError)
你会说这是本地的,但我已经用同事的电话尝试过,现在也出现了同样的错误。所以它应该在我看来代码或OpenTok库中的某个地方。
有什么想法吗?
// Handling all of our errors here by alerting them
function handleError(error) {
if (error) {
alert(error.message);
}
}
// make the agent id dynamic alteron, now hardcoded
var agentIdAvailable = '007';
var SERVER_BASE_URL = 'https://XXX.herokuapp.com';
fetch(SERVER_BASE_URL + '/room/'+ agentIdAvailable).then(function(res) {
return res.json()
}).then(function(res) {
apiKey = res.apiKey;
sessionId = res.sessionId;
token = res.token;
initializeSession();
}).catch(handleError);
function initializeSession() {
var session = OT.initSession(apiKey, sessionId);
// Subscribe to a newly created stream
session.on('streamCreated', function(event) {
session.subscribe(event.stream, 'subscriber', {
insertMode: 'append',
width: '100%',
height: '100%'
}, handleError);
});
// Create a publisher
var publisher = OT.initPublisher('publisher', {
insertMode: 'append',
width: '100%',
height: '100%'
}, handleError);
// Connect to the session
session.connect(token, function(error) {
// If the connection is successful, initialize a publisher and publish to the session
if (error) {
handleError(error);
} else {
session.publish(publisher, handleError);
console.log('*** publishing', publisher);
}
});
}