Continue screen sharing
This commit is contained in:
parent
81c030392f
commit
fe739f4f08
3 changed files with 51 additions and 5 deletions
2
front/dist/index.html
vendored
2
front/dist/index.html
vendored
|
@ -34,6 +34,8 @@
|
|||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
<div id="activeScreenSharing" class="active-screen-sharing active">
|
||||
</div>
|
||||
<audio id="audio-webrtc-in">
|
||||
<source src="/resources/objects/webrtc-in.mp3" type="audio/mp3">
|
||||
</audio>
|
||||
|
|
30
front/dist/resources/style/style.css
vendored
30
front/dist/resources/style/style.css
vendored
|
@ -152,4 +152,34 @@ video{
|
|||
top: calc(48px - 37px);
|
||||
left: calc(48px - 41px);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/*SCREEN SHARING*/
|
||||
.active-screen-sharing video{
|
||||
transform: scaleX(1);
|
||||
}
|
||||
.active-screen-sharing .screen-sharing-video-container video:hover{
|
||||
width: 50%;
|
||||
}
|
||||
.active-screen-sharing .screen-sharing-video-container video{
|
||||
position: absolute;
|
||||
width: 25%;
|
||||
height: auto;
|
||||
left: 0;
|
||||
top: 0;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.active-screen-sharing .screen-sharing-video-container video:nth-child(1){
|
||||
/*this is for camera of user*/
|
||||
top: 0%;
|
||||
}
|
||||
.active-screen-sharing .screen-sharing-video-container video:nth-child(2){
|
||||
top: 25%;
|
||||
}
|
||||
.active-screen-sharing .screen-sharing-video-container video:nth-child(3){
|
||||
top: 50%;
|
||||
}
|
||||
.active-screen-sharing .screen-sharing-video-container video:nth-child(4) {
|
||||
top: 75%;
|
||||
}
|
|
@ -248,13 +248,21 @@ export class SimplePeer {
|
|||
*/
|
||||
private addMedia (userId : any = null) {
|
||||
try {
|
||||
let localStream: MediaStream | null = this.MediaManager.localStream;
|
||||
let localScreenCapture: MediaStream | null = this.MediaManager.localScreenCapture;
|
||||
let PeerConnection = this.PeerConnectionArray.get(userId);
|
||||
|
||||
if (!PeerConnection) {
|
||||
throw new Error('While adding media, cannot find user with ID ' + userId);
|
||||
}
|
||||
|
||||
if(userId.indexOf("screenSharing") > -1 && this.MediaManager.localScreenCapture){
|
||||
for (const track of this.MediaManager.localScreenCapture.getTracks()) {
|
||||
PeerConnection.addTrack(track, this.MediaManager.localScreenCapture);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let localStream: MediaStream | null = this.MediaManager.localStream;
|
||||
let localScreenCapture: MediaStream | null = this.MediaManager.localScreenCapture;
|
||||
|
||||
PeerConnection.write(new Buffer(JSON.stringify(Object.assign(this.MediaManager.constraintsMedia, {screen: localScreenCapture !== null}))));
|
||||
|
||||
if(!localStream){
|
||||
|
@ -280,15 +288,21 @@ export class SimplePeer {
|
|||
if (this.MediaManager.localScreenCapture) {
|
||||
let screenSharingUser: UserSimplePeerInterface = {
|
||||
userId: `screenSharing-${this.Connection.userId}`,
|
||||
name: 'screenSharing',
|
||||
initiator: true
|
||||
};
|
||||
let PeerConnectionScreenSharing = this.createPeerConnection(screenSharingUser);
|
||||
if (!PeerConnectionScreenSharing) {
|
||||
return;
|
||||
}
|
||||
for (const track of this.MediaManager.localScreenCapture.getTracks()) {
|
||||
PeerConnectionScreenSharing.addTrack(track, this.MediaManager.localScreenCapture);
|
||||
try {
|
||||
for (const track of this.MediaManager.localScreenCapture.getTracks()) {
|
||||
PeerConnectionScreenSharing.addTrack(track, this.MediaManager.localScreenCapture);
|
||||
}
|
||||
}catch (e) {
|
||||
console.error("updatedScreenSharing => ", e);
|
||||
}
|
||||
this.MediaManager.addStreamRemoteVideo(screenSharingUser.userId, this.MediaManager.localScreenCapture);
|
||||
} else {
|
||||
if (!this.PeerConnectionArray.has(`screenSharing-${this.Connection.userId}`)) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue