Skip to content

Commit 17a557f

Browse files
committed
Fixed avatar and device camera bug
1 parent 6af2bf4 commit 17a557f

File tree

6 files changed

+72
-38
lines changed

6 files changed

+72
-38
lines changed

front/openvidu-call/package-lock.json

Lines changed: 40 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/openvidu-call/src/app/shared/components/dialog-choose-room/dialog-choose-room.component.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ button {
127127
}
128128

129129
#avatarImg {
130-
height: 88%;
131-
width: 88%;
130+
height: 83%;
131+
width: 83%;
132132
}
133133

134134
#avatarContainer,
135135
#avatarImg {
136-
border-radius: 50%;
136+
border-radius: 25%;
137137
}
138138

139139
#optionsContent {

front/openvidu-call/src/app/shared/components/dialog-choose-room/dialog-choose-room.component.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,16 @@ <h3 id="sessionInfo">Session : {{ mySessionId }}</h3>
4545
<h3 style="margin: auto;">Avatar</h3>
4646
</div>
4747
<div class="" fxFlex="70" fxLayoutAlign="center center">
48-
<div id="avatarContainer" (mouseover)="hover1 = true" (click)="setAvatar('video')"
49-
(mouseleave)="hover1 = false"
50-
[ngStyle]="{ backgroundColor: videoAvatar && hover1 && avatarSelected !== 'video' ? 'lightgreen' : 'white' }"
48+
<div id="avatarContainer" (click)="setAvatar('video')"
49+
50+
5151
[style.background]="avatarSelected === 'video' ? 'lightgreen' : 'transparent'">
5252
<div id="imgText" *ngIf="!videoAvatar">
5353
<span>Press Avatar Button</span>
5454
</div>
5555
<img id="avatarImg" *ngIf="videoAvatar" [src]="videoAvatar" />
5656
</div>
57-
<div id="avatarContainer" (click)="setAvatar('random')" (mouseover)="hover2 = true"
58-
(mouseleave)="hover2 = false" [ngStyle]="{
59-
backgroundColor: randomAvatar && hover2 && avatarSelected !== 'random' ? 'lightgreen' : 'white'
60-
}" [style.background]="avatarSelected === 'random' ? 'lightgreen' : 'transparent'">
57+
<div id="avatarContainer" (click)="setAvatar('random')" [style.background]="avatarSelected === 'random' ? 'lightgreen' : 'transparent'">
6158
<mat-spinner id="imgText" [diameter]="70" *ngIf="!randomAvatar" color="accent"></mat-spinner>
6259
<img id="avatarImg" *ngIf="randomAvatar" [src]="randomAvatar" />
6360
</div>

front/openvidu-call/src/app/shared/components/dialog-choose-room/dialog-choose-room.component.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { FormControl, Validators } from '@angular/forms';
33
import { UserModel } from '../../models/user-model';
44
import { NicknameMatcher } from '../../forms-matchers/nickname';
55
import { ApiService } from '../../services/api.service';
6-
import { OpenVidu, Publisher } from 'openvidu-browser';
6+
import { OpenVidu, Publisher, Device } from 'openvidu-browser';
77
import { ActivatedRoute, Params } from '@angular/router';
88
import { OvSettings } from '../../models/ov-settings';
9+
import { MatDialog } from '@angular/material/dialog';
10+
import { DialogErrorComponent } from '../dialog-error/dialog-error.component';
911

1012
interface IDevices {
1113
label: string;
@@ -50,10 +52,25 @@ export class DialogChooseRoomComponent implements OnInit {
5052
nicknameFormControl = new FormControl('', [Validators.maxLength(25), Validators.required]);
5153
matcher = new NicknameMatcher();
5254

53-
constructor(private route: ActivatedRoute, private apiSrv: ApiService) {}
55+
constructor(private route: ActivatedRoute, private apiSrv: ApiService, public dialog: MatDialog) {}
5456

5557
ngOnInit() {
58+
59+
5660
this.OV = new OpenVidu();
61+
this.OV.getDevices().then((devices: Device[]) => {
62+
console.log(devices);
63+
const haveCamera = devices.filter(device => device.kind === 'videoinput');
64+
console.log(haveCamera);
65+
if (haveCamera.length === 0) {
66+
const message = 'It looks like that you do not have any cameras available on your PC. Please, check your devices and connect a webcam to start :)'
67+
this.dialog.open(DialogErrorComponent, {
68+
width: '450px',
69+
data: { message: 'Device Error', messageError: message },
70+
});
71+
}
72+
73+
});
5774
this.localUsers.push(new UserModel());
5875
this.generateNickname();
5976
this.setSessionName();
@@ -243,11 +260,9 @@ export class DialogChooseRoomComponent implements OnInit {
243260
}
244261

245262
private getRandomAvatar() {
246-
this.apiSrv.getRandomAvatar().then((avatar: string) => {
247-
this.randomAvatar = avatar;
248-
this.setAvatar('random');
249-
})
250-
.catch((err) => console.error(err));
263+
this.randomAvatar = this.apiSrv.getRandomAvatar();
264+
this.avatarSelected = 'random';
265+
this.setAvatar('random');
251266
}
252267

253268
private initPublisher(): Promise<any> {

front/openvidu-call/src/app/shared/services/api.service.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ export class ApiService {
4545
}
4646
}
4747

48-
public getRandomAvatar(): Promise<string> {
49-
return new Promise((resolve, reject) => {
50-
this.http.get('https://randomuser.me/api/?lego').subscribe((data: any) => {
51-
resolve(data.results[0].picture.thumbnail);
52-
});
53-
});
48+
public getRandomAvatar(): string {
49+
return 'https://openvidu.io/img/logos/openvidu_globe_bg_transp_cropped.png'
5450
}
5551

5652
public handlerScreenShareError(error: any) {

front/openvidu-call/src/app/shared/services/openvidu.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { OvSettings } from '../models/ov-settings';
99
providedIn: 'root',
1010
})
1111
export class OpenViduService {
12-
private URL_OV = 'https://demos.openvidu.io' + ':4443';
12+
private URL_OV = 'https://' + location.hostname + ':4443';
1313
private MY_SECRET = 'MY_SECRET';
1414
private SETTINGS_FILE_NAME = 'ov-settings.json';
1515

0 commit comments

Comments
 (0)