fix(tracker-assist):3.0.3 hack to enable audio from iframe

This commit is contained in:
ShiKhu 2021-08-17 14:35:41 +08:00
parent ddedcf7172
commit 194d1b4d9e
3 changed files with 27 additions and 17 deletions

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker-assist",
"description": "Tracker plugin for screen assistance through the WebRTC",
"version": "3.0.2",
"version": "3.0.3",
"keywords": [
"WebRTC",
"assistance",

View file

@ -101,15 +101,22 @@ export default class CallWindow {
}
private aRemote: HTMLAudioElement | null = null;
private localStream: MediaStream | null = null;
private remoteStream: MediaStream | null = null;
private setLocalVideoStream: (MediaStream) => void = () => {};
private videoRequested: boolean = true; // TODO: green camera light
private _trySetStreams() {
if (this.vRemote && this.remoteStream) {
if (this.vRemote && !this.vRemote.srcObject && this.remoteStream) {
this.vRemote.srcObject = this.remoteStream;
// Hack for audio (doesen't work in iframe because of some magical reasons)
this.aRemote = document.createElement("audio");
this.aRemote.autoplay = true;
this.aRemote.style.display = "none"
this.aRemote.srcObject = this.remoteStream;
document.body.appendChild(this.aRemote)
}
if (this.vLocal && this.localStream) {
if (this.vLocal && !this.vLocal.srcObject && this.localStream) {
this.vLocal.srcObject = this.localStream;
}
}
@ -195,6 +202,9 @@ export default class CallWindow {
if (this.iframe.parentElement) {
document.body.removeChild(this.iframe);
}
if (this.aRemote && this.aRemote.parentElement) {
document.body.removeChild(this.aRemote);
}
}
}

View file

@ -164,20 +164,20 @@ export default function(opts: Partial<Options> = {}) {
});
call.on('stream', function(rStream) {
callUI.setRemoteStream(rStream);
dataConn.on('data', (data: any) => {
if (data === "call_end") {
//console.log('receiving callend on call')
onCallEnd();
return;
}
if (data && typeof data.name === 'string') {
//console.log("name",data)
callUI.setAssistentName(data.name);
}
if (data && typeof data.x === 'number' && typeof data.y === 'number') {
mouse.move(data);
}
});
});
dataConn.on('data', (data: any) => {
if (data === "call_end") {
//console.log('receiving callend on call')
onCallEnd();
return;
}
if (data && typeof data.name === 'string') {
//console.log("name",data)
callUI.setAssistentName(data.name);
}
if (data && typeof data.x === 'number' && typeof data.y === 'number') {
mouse.move(data);
}
});
}