无法读取未定义的 属性 'getUserMedia' [React Native]
Cannot read property 'getUserMedia' of undefined [React Native]
我创建了一个videochatconference会话,可以通过ID进入聊天室查看参与者。但是,当我尝试使用 getUserMedia 获取本地用户流时,它 returns 未定义函数的错误
this._session = ConnectyCube.videochatconference.createNewSession();
this._session.getUserMedia({
audio: true,
video: { facingMode: 'user' }
})
.then(localStream => {
console.log(localStream);
})
.catch((error) => {
console.log(error);
});
this._session.join('xxxxxxxxxx', userCredentials.id, userCredentials.login)
这是我的测试代码的另一个视图
const env = Configs.connectyCube;
const { credentials, config } = env;
let userCredentials = {
id: 123,
login: 'xxxxxx',
password: '*****',
};
ConnectyCube.init(credentials, config);
ConnectyCube.createSession(userCredentials)
.then(session => {
ConnectyCube.chat.connect({
userId: userCredentials.id,
password: userCredentials.password
});
ConnectyCube.login(userCredentials)
.then((user) => {
console.log(user);
const opponentsIds = users.filter(opponent => opponent.id !== userCredentials.id);
.map(opponent => opponent.id);
console.log(opponentsIds);
this._session = ConnectyCube.videochatconference.createNewSession();
this._session.getUserMedia({
audio: true,
video: { facingMode: 'user' }
})
.then(localStream => {
console.log(localStream);
})
.catch((error) => {
console.log(error);
})
})
.catch((error) => {
console.log(error);
});
}).catch(error => {
console.log(error);
});
使用:
反应本机 0.62.2
react-native-connectycube 3.0.1
ConnectyCube文档中提到必须安装react-native-webrtc。
请检查以下内容:
https://developers.connectycube.com/reactnative/videocalling-conference
我创建了一个videochatconference会话,可以通过ID进入聊天室查看参与者。但是,当我尝试使用 getUserMedia 获取本地用户流时,它 returns 未定义函数的错误
this._session = ConnectyCube.videochatconference.createNewSession();
this._session.getUserMedia({
audio: true,
video: { facingMode: 'user' }
})
.then(localStream => {
console.log(localStream);
})
.catch((error) => {
console.log(error);
});
this._session.join('xxxxxxxxxx', userCredentials.id, userCredentials.login)
这是我的测试代码的另一个视图
const env = Configs.connectyCube;
const { credentials, config } = env;
let userCredentials = {
id: 123,
login: 'xxxxxx',
password: '*****',
};
ConnectyCube.init(credentials, config);
ConnectyCube.createSession(userCredentials)
.then(session => {
ConnectyCube.chat.connect({
userId: userCredentials.id,
password: userCredentials.password
});
ConnectyCube.login(userCredentials)
.then((user) => {
console.log(user);
const opponentsIds = users.filter(opponent => opponent.id !== userCredentials.id);
.map(opponent => opponent.id);
console.log(opponentsIds);
this._session = ConnectyCube.videochatconference.createNewSession();
this._session.getUserMedia({
audio: true,
video: { facingMode: 'user' }
})
.then(localStream => {
console.log(localStream);
})
.catch((error) => {
console.log(error);
})
})
.catch((error) => {
console.log(error);
});
}).catch(error => {
console.log(error);
});
使用: 反应本机 0.62.2 react-native-connectycube 3.0.1
ConnectyCube文档中提到必须安装react-native-webrtc。
请检查以下内容: https://developers.connectycube.com/reactnative/videocalling-conference