-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7a40a3
commit 6743a09
Showing
4 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="participant-action"> | ||
<button class="btn-mic-off"></button> | ||
<button class="btn-camera-off"></button> | ||
<md-switch id="switch-{{ guest?.stream?.id }}" icons class="active-video" | ||
(click)="toggleActive()"></md-switch> | ||
</div> | ||
<a href="#" class="name-tag">{{ guest?.user?.name }}</a> | ||
<video id="video-{{ guest?.stream?.id }}" #videoElement muted autoplay></video> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
AfterViewInit, | ||
Component, ElementRef, | ||
HostBinding, | ||
Input, | ||
OnDestroy, ViewChild, | ||
ViewEncapsulation | ||
} from '@angular/core'; | ||
import {Guest} from '../../entities'; | ||
|
||
@Component({ | ||
selector: 'shig-guest', | ||
templateUrl: './guest.component.html', | ||
styleUrls: [ | ||
'./../../../../assets/scss/lobby.scss', | ||
'./../../../../assets/scss/styles.scss' | ||
], | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class GuestComponent implements AfterViewInit, OnDestroy { | ||
|
||
@HostBinding('class.guest-video') public hostClass = true; | ||
@ViewChild('videoElement') videoRef!: ElementRef<HTMLVideoElement>; | ||
|
||
@Input() activateGuestStreamCbk!: (g: Guest) => void; | ||
@Input() deactivateGuestStreamCbk!: (g: Guest) => void; | ||
@Input('guest') guest!: Guest; | ||
|
||
ngAfterViewInit() { | ||
this.getVideoElement().srcObject = this.guest?.stream; | ||
} | ||
|
||
public updateGuest(guest: Guest): void { | ||
const oldGuest = this.guest; | ||
this.guest = guest; | ||
this.getVideoElement().srcObject = this.guest?.stream; | ||
if (oldGuest.stream.id !== this.guest.stream.id) { | ||
// if get a complete new stream, stop the old stream | ||
// this happens often for local users | ||
oldGuest.stopStream(); | ||
} | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.getVideoElement().srcObject = null; | ||
this.guest.stopStream(); | ||
} | ||
|
||
toggleActive() { | ||
const shadowRoot = document.getElementById(`switch-${this.guest.stream.id}`)?.shadowRoot; | ||
const isSelected = !shadowRoot?.querySelector('div')?.classList.contains('selected'); | ||
|
||
if (isSelected) { | ||
this.activateGuestStreamCbk(this.guest); | ||
} else { | ||
this.deactivateGuestStreamCbk(this.guest); | ||
} | ||
} | ||
|
||
private getVideoElement(): HTMLVideoElement { | ||
return this.videoRef.nativeElement; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters