v1.7.0/video calling
This commit is contained in:
+2
-2
@@ -11,8 +11,8 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
/*global chrome*/
|
/*global chrome*/
|
||||||
|
|
||||||
// const API_HOST = 'https://api.chromewatchparty.com';
|
const API_HOST = 'https://api.chromewatchparty.com';
|
||||||
const API_HOST = 'http://localhost:5000/watch-party-crx/us-central1/widgets';
|
// const API_HOST = 'http://localhost:5000/watch-party-crx/us-central1/widgets';
|
||||||
|
|
||||||
export const PLAYER_STATUS = {
|
export const PLAYER_STATUS = {
|
||||||
PLAYING: 'PLAYING',
|
PLAYING: 'PLAYING',
|
||||||
|
|||||||
+67
-8
@@ -27,13 +27,14 @@ export default class CallManager {
|
|||||||
this.__sessionInitialized = false;
|
this.__sessionInitialized = false;
|
||||||
this.__admin = false;
|
this.__admin = false;
|
||||||
this.__adminOnly = true;
|
this.__adminOnly = true;
|
||||||
|
this.__useVideo = false;
|
||||||
}
|
}
|
||||||
toggleCall(onCall, conference, admin, adminOnly, useVideo) {
|
toggleCall(onCall, conference, admin, adminOnly, useVideo) {
|
||||||
console.log('USE VIDEO', useVideo);
|
|
||||||
try {
|
try {
|
||||||
this.listener({ callActionPending: true });
|
this.listener({ callActionPending: true });
|
||||||
this.__admin = admin;
|
this.__admin = admin;
|
||||||
this.__adminOnly = adminOnly;
|
this.__adminOnly = adminOnly;
|
||||||
|
this.__useVideo = useVideo;
|
||||||
if (onCall === true) this.leaveCall();
|
if (onCall === true) this.leaveCall();
|
||||||
else this.boot(conference, useVideo);
|
else this.boot(conference, useVideo);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -46,8 +47,15 @@ export default class CallManager {
|
|||||||
this.listener({ muted: !muted, callActionPending: false });
|
this.listener({ muted: !muted, callActionPending: false });
|
||||||
}
|
}
|
||||||
toggleVideo(useVideo) {
|
toggleVideo(useVideo) {
|
||||||
console.log(useVideo);
|
if (useVideo === true) {
|
||||||
|
VoxeetSDK.conference.startVideo(VoxeetSDK.session.participant).then(() => {
|
||||||
this.listener({ usingVideo: useVideo });
|
this.listener({ usingVideo: useVideo });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
VoxeetSDK.conference.stopVideo(VoxeetSDK.session.participant).then(() => {
|
||||||
|
this.listener({ usingVideo: useVideo });
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async boot(conference, useVideo) {
|
async boot(conference, useVideo) {
|
||||||
await this.initialize();
|
await this.initialize();
|
||||||
@@ -93,6 +101,7 @@ export default class CallManager {
|
|||||||
onCall: false,
|
onCall: false,
|
||||||
muted: false,
|
muted: false,
|
||||||
callActionPending: false,
|
callActionPending: false,
|
||||||
|
usingVideo: false,
|
||||||
});
|
});
|
||||||
console.error('Update Voxeet API Error', err);
|
console.error('Update Voxeet API Error', err);
|
||||||
return false;
|
return false;
|
||||||
@@ -105,6 +114,7 @@ export default class CallManager {
|
|||||||
onCall: false,
|
onCall: false,
|
||||||
muted: false,
|
muted: false,
|
||||||
callActionPending: false,
|
callActionPending: false,
|
||||||
|
usingVideo: false,
|
||||||
});
|
});
|
||||||
console.error('Failed to update party Voxeet');
|
console.error('Failed to update party Voxeet');
|
||||||
}
|
}
|
||||||
@@ -123,11 +133,15 @@ export default class CallManager {
|
|||||||
onCall: false,
|
onCall: false,
|
||||||
muted: false,
|
muted: false,
|
||||||
callActionPending: false,
|
callActionPending: false,
|
||||||
|
usingVideo: false,
|
||||||
});
|
});
|
||||||
this.notify('Unable to join call. Try again in a moment.');
|
this.notify('Unable to join call. Try again in a moment.');
|
||||||
console.error('Error joining call', e);
|
console.error('Error joining call', e);
|
||||||
return true;
|
return false;
|
||||||
});
|
});
|
||||||
|
if (joined === true) {
|
||||||
|
this.listener({ usingVideo: useVideo });
|
||||||
|
}
|
||||||
// Leave changes as comment for later
|
// Leave changes as comment for later
|
||||||
// if (!joined) {
|
// if (!joined) {
|
||||||
// this.startCall(useVideo);
|
// this.startCall(useVideo);
|
||||||
@@ -136,7 +150,19 @@ export default class CallManager {
|
|||||||
async leaveCall() {
|
async leaveCall() {
|
||||||
VoxeetSDK.conference.leave().then(() => {
|
VoxeetSDK.conference.leave().then(() => {
|
||||||
VoxeetSDK.session.close();
|
VoxeetSDK.session.close();
|
||||||
this.listener({ onCall: false, muted: false, callActionPending: false, usingVideo: false });
|
this.listener({
|
||||||
|
onCall: false,
|
||||||
|
muted: false,
|
||||||
|
callActionPending: false,
|
||||||
|
usingVideo: false,
|
||||||
|
conference: null,
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.vxt-video').forEach((v) => {
|
||||||
|
v.srcObject.getTracks().forEach((track) => {
|
||||||
|
track.stop();
|
||||||
|
});
|
||||||
|
v.remove();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async openSession() {
|
async openSession() {
|
||||||
@@ -167,7 +193,7 @@ export default class CallManager {
|
|||||||
VoxeetSDK.conference.on('participantUpdated', () => this.usersListHandle());
|
VoxeetSDK.conference.on('participantUpdated', () => this.usersListHandle());
|
||||||
|
|
||||||
VoxeetSDK.conference.on('joined', () => {
|
VoxeetSDK.conference.on('joined', () => {
|
||||||
this.listener({ onCall: true, callActionPending: false });
|
this.listener({ onCall: true, callActionPending: false, usingVideo: this.__useVideo });
|
||||||
});
|
});
|
||||||
|
|
||||||
VoxeetSDK.conference.on('left', () => {
|
VoxeetSDK.conference.on('left', () => {
|
||||||
@@ -175,14 +201,47 @@ export default class CallManager {
|
|||||||
onCall: false,
|
onCall: false,
|
||||||
callActionPending: false,
|
callActionPending: false,
|
||||||
usersOnCall: {},
|
usersOnCall: {},
|
||||||
|
usingVideo: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
VoxeetSDK.conference.on('streamAdded', (participant, stream) => {
|
VoxeetSDK.conference.on('streamAdded', (participant, stream) => {
|
||||||
|
this.listener({ callActionPending: true });
|
||||||
|
if (this.__useVideo === true) {
|
||||||
|
const vid = 'video#' + LocalData().userUid;
|
||||||
|
if (!document.querySelector(vid)) {
|
||||||
|
const vidNode = document.createElement('video');
|
||||||
|
vidNode.id = LocalData().userUid;
|
||||||
|
vidNode.classList.add('vxt-video');
|
||||||
|
document.querySelector('.vxt-video-container').appendChild(vidNode);
|
||||||
|
navigator
|
||||||
|
.getUserMedia({
|
||||||
|
video: true,
|
||||||
|
audio: false,
|
||||||
|
})
|
||||||
|
.then((stream) => {
|
||||||
|
vidNode.srcObject = stream;
|
||||||
|
vidNode.onloadedmetadata = vidNode.play;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
//ignore
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
this.listener({ callActionPending: false });
|
this.listener({ callActionPending: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
VoxeetSDK.conference.on('streamRemoved', (participant, stream) => {
|
VoxeetSDK.conference.on('streamRemoved', (participant, stream) => {
|
||||||
|
const vid = 'video#' + participant.id;
|
||||||
|
if (document.querySelector(vid)) {
|
||||||
|
document
|
||||||
|
.querySelector(vid)
|
||||||
|
.srcObject.getTracks()
|
||||||
|
.forEach((track) => {
|
||||||
|
track.stop();
|
||||||
|
});
|
||||||
|
document.querySelector(vid).remove();
|
||||||
|
}
|
||||||
this.listener({ callActionPending: false });
|
this.listener({ callActionPending: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -194,11 +253,11 @@ export default class CallManager {
|
|||||||
) {
|
) {
|
||||||
await GetVoxeetTokenApi({ partyName: LocalData().partyName })
|
await GetVoxeetTokenApi({ partyName: LocalData().partyName })
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((tokenResult) => {
|
.then(async (tokenResult) => {
|
||||||
if (tokenResult.status <= 299) {
|
if (tokenResult.status <= 299) {
|
||||||
const { access_token, refresh_token } = tokenResult;
|
const { access_token, refresh_token } = tokenResult;
|
||||||
this.updateTokens(access_token, refresh_token);
|
this.updateTokens(access_token, refresh_token);
|
||||||
VoxeetSDK.initializeToken(access_token, refresh_token);
|
await VoxeetSDK.initializeToken(access_token, refresh_token);
|
||||||
} else {
|
} else {
|
||||||
console.error('Get Voxeet Token API Result Error', tokenResult);
|
console.error('Get Voxeet Token API Result Error', tokenResult);
|
||||||
}
|
}
|
||||||
@@ -207,7 +266,7 @@ export default class CallManager {
|
|||||||
console.error('Get Voxeet Token API error', err);
|
console.error('Get Voxeet Token API error', err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
VoxeetSDK.initializeToken(this.__accessToken, this.__refreshToken);
|
await VoxeetSDK.initializeToken(this.__accessToken, this.__refreshToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async refreshToken() {
|
async refreshToken() {
|
||||||
|
|||||||
+2
-1
@@ -394,7 +394,7 @@ export default class Chat extends Component {
|
|||||||
const overlay = document.createElement('div');
|
const overlay = document.createElement('div');
|
||||||
overlay.innerHTML = `
|
overlay.innerHTML = `
|
||||||
<div id="mic-highlight"></div>
|
<div id="mic-highlight"></div>
|
||||||
<h4 id="mic-text">Grant Mic Permission</h4>
|
<h4 id="mic-text">Grant Mic / Camera Permission</h4>
|
||||||
`;
|
`;
|
||||||
overlay.id = 'mic-permission-overlay';
|
overlay.id = 'mic-permission-overlay';
|
||||||
document.body.appendChild(overlay);
|
document.body.appendChild(overlay);
|
||||||
@@ -803,6 +803,7 @@ export default class Chat extends Component {
|
|||||||
} else return null;
|
} else return null;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="vxt-video-container"></div>
|
||||||
<Thread setReplyTo={this.setReplyTo} sentMessages={messages} />
|
<Thread setReplyTo={this.setReplyTo} sentMessages={messages} />
|
||||||
<Thread
|
<Thread
|
||||||
isSending={true}
|
isSending={true}
|
||||||
|
|||||||
@@ -965,3 +965,14 @@ button.giphy-list-item {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vxt-video-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
}
|
||||||
|
.vxt-video {
|
||||||
|
max-width: calc(50% - 20px) !important;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: 10px 15px;
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user