v1.7.0/start of video call
- remove user check updatePlayer api
This commit is contained in:
+18
-13
@@ -28,13 +28,14 @@ export default class CallManager {
|
||||
this.__admin = false;
|
||||
this.__adminOnly = true;
|
||||
}
|
||||
toggleCall(onCall, conference, admin, adminOnly) {
|
||||
toggleCall(onCall, conference, admin, adminOnly, useVideo) {
|
||||
console.log('USE VIDEO', useVideo);
|
||||
try {
|
||||
this.listener({ callActionPending: true });
|
||||
this.__admin = admin;
|
||||
this.__adminOnly = adminOnly;
|
||||
if (onCall === true) this.leaveCall();
|
||||
else this.boot(conference);
|
||||
else this.boot(conference, useVideo);
|
||||
} catch (e) {
|
||||
this.notify('Uh oh something went wrong, try rejoining the call.');
|
||||
}
|
||||
@@ -44,25 +45,29 @@ export default class CallManager {
|
||||
VoxeetSDK.conference.mute(VoxeetSDK.session.participant, !muted);
|
||||
this.listener({ muted: !muted, callActionPending: false });
|
||||
}
|
||||
async boot(conference) {
|
||||
toggleVideo(useVideo) {
|
||||
console.log(useVideo);
|
||||
this.listener({ usingVideo: useVideo });
|
||||
}
|
||||
async boot(conference, useVideo) {
|
||||
await this.initialize();
|
||||
const opened = await this.openSession();
|
||||
if (opened && conference) {
|
||||
await VoxeetSDK.conference
|
||||
.fetch(conference._id)
|
||||
.then(this.joinCall)
|
||||
.then((c) => this.joinCall(c, useVideo))
|
||||
.catch((err) => {
|
||||
console.error('Failed to fetch conference', err);
|
||||
this.startCall();
|
||||
this.startCall(useVideo);
|
||||
});
|
||||
} else if (opened && !conference) {
|
||||
this.startCall();
|
||||
this.startCall(useVideo);
|
||||
} else {
|
||||
this.listener({ onCall: false, muted: false, callActionPending: false });
|
||||
console.error('Unable to open Voxeet Session');
|
||||
}
|
||||
}
|
||||
async startCall() {
|
||||
async startCall(useVideo) {
|
||||
if (!this.__adminOnly || (this.__adminOnly && this.__admin)) {
|
||||
VoxeetSDK.conference
|
||||
.create({
|
||||
@@ -80,7 +85,7 @@ export default class CallManager {
|
||||
.then((res) => res.status <= 299)
|
||||
.catch((err) => {
|
||||
if (err.conference) {
|
||||
this.joinCall(err.conference);
|
||||
this.joinCall(err.conference, useVideo);
|
||||
return true;
|
||||
} else {
|
||||
this.notify(err.message);
|
||||
@@ -94,7 +99,7 @@ export default class CallManager {
|
||||
}
|
||||
});
|
||||
if (updatedVoxeet === true) {
|
||||
this.joinCall(conference);
|
||||
this.joinCall(conference, useVideo);
|
||||
} else {
|
||||
this.listener({
|
||||
onCall: false,
|
||||
@@ -109,9 +114,9 @@ export default class CallManager {
|
||||
this.leaveCall();
|
||||
}
|
||||
}
|
||||
async joinCall(conference) {
|
||||
async joinCall(conference, useVideo) {
|
||||
const joined = await VoxeetSDK.conference
|
||||
.join(conference, { constraints: { audio: true, video: false } })
|
||||
.join(conference, { constraints: { audio: true, video: useVideo } })
|
||||
.then(() => true)
|
||||
.catch((e) => {
|
||||
this.listener({
|
||||
@@ -125,13 +130,13 @@ export default class CallManager {
|
||||
});
|
||||
// Leave changes as comment for later
|
||||
// if (!joined) {
|
||||
// this.startCall();
|
||||
// this.startCall(useVideo);
|
||||
// }
|
||||
}
|
||||
async leaveCall() {
|
||||
VoxeetSDK.conference.leave().then(() => {
|
||||
VoxeetSDK.session.close();
|
||||
this.listener({ onCall: false, muted: false, callActionPending: false });
|
||||
this.listener({ onCall: false, muted: false, callActionPending: false, usingVideo: false });
|
||||
});
|
||||
}
|
||||
async openSession() {
|
||||
|
||||
Reference in New Issue
Block a user