Add button to enter un visio
This commit is contained in:
parent
707931724f
commit
b49c012319
7 changed files with 91 additions and 12 deletions
|
@ -1,25 +1,23 @@
|
|||
export class MediaManager {
|
||||
localStream: MediaStream;
|
||||
remoteStream: MediaStream;
|
||||
remoteVideo: Array<any> = new Array<any>();
|
||||
myCamVideo: any;
|
||||
cinemaClose: any = null;
|
||||
cinema: any = null;
|
||||
microphoneClose: any = null;
|
||||
microphone: any = null;
|
||||
constraintsMedia = {audio: true, video: true};
|
||||
constraintsMedia = {audio: false, video: true};
|
||||
getCameraPromise : Promise<any> = null;
|
||||
|
||||
constructor() {
|
||||
this.myCamVideo = document.getElementById('myCamVideo');
|
||||
|
||||
this.microphoneClose = document.getElementById('microphone-close');
|
||||
|
||||
this.microphoneClose.addEventListener('click', (e: any) => {
|
||||
e.preventDefault();
|
||||
this.enabledMicrophone();
|
||||
//update tracking
|
||||
});
|
||||
|
||||
this.microphone = document.getElementById('microphone');
|
||||
this.microphone.addEventListener('click', (e: any) => {
|
||||
e.preventDefault();
|
||||
|
@ -42,7 +40,9 @@ export class MediaManager {
|
|||
|
||||
this.enabledCamera();
|
||||
this.enabledMicrophone();
|
||||
}
|
||||
|
||||
activeVisio(){
|
||||
let webRtc = document.getElementById('webRtc');
|
||||
webRtc.classList.add('active');
|
||||
}
|
||||
|
@ -91,6 +91,18 @@ export class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
getElementActivePhone(){
|
||||
return document.getElementById('phone-open');
|
||||
}
|
||||
|
||||
activePhoneOpen(){
|
||||
return this.getElementActivePhone().classList.add("active");
|
||||
}
|
||||
|
||||
disablePhoneOpen(){
|
||||
return this.getElementActivePhone().classList.remove("active");
|
||||
}
|
||||
|
||||
//get camera
|
||||
getCamera() {
|
||||
return this.getCameraPromise = navigator.mediaDevices.getUserMedia(this.constraintsMedia)
|
||||
|
|
|
@ -3,7 +3,8 @@ import {MediaManager} from "./MediaManager";
|
|||
let Peer = require('simple-peer');
|
||||
|
||||
export interface SimplePeerInterface {
|
||||
startWebRtc(): void;
|
||||
activePhone(): void;
|
||||
disablePhone(): void;
|
||||
}
|
||||
|
||||
export class SimplePeer {
|
||||
|
@ -16,13 +17,18 @@ export class SimplePeer {
|
|||
constructor(Connexion: ConnexionInterface, roomId: string = "test-webrtc") {
|
||||
this.Connexion = Connexion;
|
||||
this.RoomId = roomId;
|
||||
this.MediaManager = new MediaManager();
|
||||
this.MediaManager.getElementActivePhone().addEventListener("click", () => {
|
||||
this.startWebRtc();
|
||||
this.disablePhone();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* server has two person connected, start the meet
|
||||
*/
|
||||
startWebRtc() {
|
||||
this.MediaManager = new MediaManager();
|
||||
this.MediaManager.activeVisio();
|
||||
return this.MediaManager.getCamera().then((stream: MediaStream) => {
|
||||
this.MediaManager.localStream = stream;
|
||||
//send message to join a room
|
||||
|
@ -126,4 +132,12 @@ export class SimplePeer {
|
|||
addMedia (userId : any) {
|
||||
this.PeerConnexionArray[userId].addStream(this.MediaManager.localStream) // <- add streams to peer dynamically
|
||||
}
|
||||
|
||||
activePhone(){
|
||||
this.MediaManager.activePhoneOpen();
|
||||
}
|
||||
|
||||
disablePhone(){
|
||||
this.MediaManager.disablePhoneOpen();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue