Я настраиваю агора SDK для моего углового проекта и получаю следующую ошибку.
Код:
Это мой пример кода и вызывает метод startCall в ngOnInit. У меня есть элемент div с идентификатором.
startCall () {
this.agoraService.client.join (null, '1000', null, (uid) => {
this.localStream = this.agoraService.createStream (uid, true, null, null, true, false);
this.localStream.setVideoProfile ( '720p_3');
this.subscribeToStreams ();
});
}
частная подписка ToStreams () {
this.localStream.on("accessAllowed", () => {
console.log("accessAllowed");
});
// The user has denied access to the camera and mic.
this.localStream.on("accessDenied", () => {
console.log("accessDenied");
});
this.localStream.init(() => {
console.log("getUserMedia successfully");
this.localStream.play('agora_local');
this.agoraService.client.publish(this.localStream, function (err) {
console.log("Publish local stream error: " + err);
});
this.agoraService.client.on('stream-published', function (evt) {
console.log("Publish local stream successfully");
});
}, function (err) {
console.log("getUserMedia failed", err);
});
// Add
this.agoraService.client.on('error', (err) => {
console.log("Got error msg:", err.reason);
if (err.reason === 'DYNAMIC_KEY_TIMEOUT') {
this.agoraService.client.renewChannelKey("", () => {
console.log("Renew channel key successfully");
}, (err) => {
console.log("Renew channel key failed: ", err);
});
}
});
// Add
this.agoraService.client.on('stream-added', (evt) => {
const stream = evt.stream;
this.agoraService.client.subscribe(stream, (err) => {
console.log("Subscribe stream failed", err);
});
});
// Add
this.agoraService.client.on('stream-subscribed', (evt) => {
const stream = evt.stream;
if (!this.remoteCalls.includes(`agora_remote${stream.getId()}`)) this.remoteCalls.push(`agora_remote${stream.getId()}`);
setTimeout(() => stream.play(`agora_remote${stream.getId()}`), 2000);
});
// Add
this.agoraService.client.on('stream-removed', (evt) => {
const stream = evt.stream;
stream.stop();
this.remoteCalls = this.remoteCalls.filter(call => call !== `#agora_remote${stream.getId()}`);
console.log(`Remote stream is removed ${stream.getId()}`);
});
// Add
this.agoraService.client.on('peer-leave', (evt) => {
const stream = evt.stream;
if (stream) {
stream.stop();
this.remoteCalls = this.remoteCalls.filter(call => call === `#agora_remote${stream.getId()}`);
console.log(`${evt.uid} left from this channel`);
}
});
}
У меня есть элемент div с идентификатором.
Uncaught (в обещании) TypeError: Не удалось выполнить 'getStats' для 'RTCPeerConnection': обратный вызов, предоставленный в качестве параметра 1, не является функцией.
at Object.C.t.getStats (AgoraRTCSDK.min.js: 2)
на AgoraRTCSDK.min.js: 2
в ZoneDelegate.push ../ node_modules / zone.js / dist / zone.js.ZoneDelegate.invokeTask (zone.js: 423)
в Zone.push ../ node_modules / zone.js / dist / zone.js.Zone.runTask (zone.js: 195)
при нажатии ../ node_modules / zone.js / dist / zone.js.ZoneTask.invokeTask (zone.js: 498)
в ZoneTask.invoke (zone.js: 487)
по таймеру (zone.js: 2281)
Кто-нибудь сталкивается с той же проблемой? Кто-нибудь может мне с этим помочь?
Спасибо.
Я перешел по этой ссылке
https://docs.agora.io/en/Interactive%20Broadcast/web_prepare?platform=Web
Шаги, которые я сделал, введите код здесь
1. Импортируйте Agora Web SDK в ваш проект
2. Создайте и инициализируйте клиента
3. Присоединиться к каналу
4. И, наконец, подписка на удаленный поток