2022-03-10 15:41:51 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2022-12-23 16:17:04 +01:00
|
|
|
import { RecordingInfo, TokenModel } from 'openvidu-angular';
|
2022-01-19 17:24:11 +01:00
|
|
|
import { RestService } from '../services/rest.service';
|
2022-04-28 13:09:42 +02:00
|
|
|
|
2022-01-19 17:24:11 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'app-call',
|
|
|
|
templateUrl: './call.component.html',
|
|
|
|
styleUrls: ['./call.component.scss']
|
|
|
|
})
|
|
|
|
export class CallComponent implements OnInit {
|
2022-04-05 15:58:12 +02:00
|
|
|
sessionId = 'daily-call';
|
2022-04-28 13:09:42 +02:00
|
|
|
tokens: TokenModel;
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
joinSessionClicked: boolean = false;
|
|
|
|
closeClicked: boolean = false;
|
|
|
|
isSessionAlive: boolean = false;
|
2022-06-22 12:42:02 +02:00
|
|
|
recordingList: RecordingInfo[] = [];
|
|
|
|
recordingError: any;
|
2023-02-17 17:03:15 +01:00
|
|
|
broadcastingError: any;
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-12-23 16:17:04 +01:00
|
|
|
constructor(private restService: RestService) {}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-10 15:41:51 +01:00
|
|
|
async ngOnInit() {
|
2022-11-04 16:24:42 +01:00
|
|
|
await this.requestForTokens();
|
|
|
|
}
|
|
|
|
|
|
|
|
async onNodeCrashed() {
|
|
|
|
// Request the tokens again for reconnect to the session
|
|
|
|
await this.requestForTokens();
|
2022-04-28 13:09:42 +02:00
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-04-28 13:09:42 +02:00
|
|
|
onJoinClicked() {
|
|
|
|
console.warn('VC JOIN BUTTON CLICKED');
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-10 15:41:51 +01:00
|
|
|
onToolbarCameraButtonClicked() {
|
|
|
|
console.warn('VC camera CLICKED');
|
|
|
|
}
|
|
|
|
onToolbarMicrophoneButtonClicked() {
|
|
|
|
console.warn('VC microphone CLICKED');
|
|
|
|
}
|
|
|
|
onToolbarScreenshareButtonClicked() {
|
|
|
|
console.warn('VC screenshare CLICKED');
|
|
|
|
}
|
|
|
|
onToolbarFullscreenButtonClicked() {
|
|
|
|
console.warn('VC fullscreen CLICKED');
|
|
|
|
}
|
|
|
|
onToolbarParticipantsPanelButtonClicked() {
|
|
|
|
console.warn('VC participants CLICKED');
|
|
|
|
}
|
|
|
|
onToolbarChatPanelButtonClicked() {
|
|
|
|
console.warn('VC chat CLICKED');
|
2022-02-03 17:08:23 +01:00
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-10 15:41:51 +01:00
|
|
|
onToolbarLeaveButtonClicked() {
|
|
|
|
this.isSessionAlive = false;
|
|
|
|
console.log('VC LEAVE BUTTON CLICKED');
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-10 15:41:51 +01:00
|
|
|
onCameraButtonClicked() {
|
|
|
|
console.warn('TOOLBAR camera CLICKED');
|
|
|
|
}
|
|
|
|
onMicrophoneButtonClicked() {
|
|
|
|
console.warn('TOOLBAR microphone CLICKED');
|
|
|
|
}
|
|
|
|
onScreenshareButtonClicked() {
|
|
|
|
console.warn('TOOLBAR screenshare CLICKED');
|
|
|
|
}
|
|
|
|
onFullscreenButtonClicked() {
|
|
|
|
console.warn('TOOLBAR fullscreen CLICKED');
|
|
|
|
}
|
|
|
|
onParticipantsPanelButtonClicked() {
|
|
|
|
console.warn('TOOLBAR participants CLICKED');
|
|
|
|
}
|
|
|
|
onChatPanelButtonClicked() {
|
|
|
|
console.warn('TOOLBAR chat CLICKED');
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-10 15:41:51 +01:00
|
|
|
onLeaveButtonClicked() {
|
2022-01-19 17:24:11 +01:00
|
|
|
this.isSessionAlive = false;
|
2022-03-10 15:41:51 +01:00
|
|
|
console.log('TOOLBAR LEAVE CLICKED');
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
2022-06-22 12:42:02 +02:00
|
|
|
|
2023-02-17 17:03:15 +01:00
|
|
|
async onStartBroadcastingClicked(broadcastUrl: string) {
|
|
|
|
console.log('START STREAMING', broadcastUrl);
|
2022-12-23 16:17:04 +01:00
|
|
|
try {
|
2023-02-17 17:03:15 +01:00
|
|
|
this.broadcastingError = null;
|
|
|
|
const resp = await this.restService.startBroadcasting(broadcastUrl);
|
|
|
|
console.log('Broadcasting response ', resp);
|
2022-12-23 16:17:04 +01:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2023-02-17 17:03:15 +01:00
|
|
|
this.broadcastingError = error.error;
|
2022-12-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-17 17:03:15 +01:00
|
|
|
async onStopBroadcastingClicked() {
|
2022-12-23 16:17:04 +01:00
|
|
|
console.log('STOP STREAMING');
|
|
|
|
try {
|
2023-02-17 17:03:15 +01:00
|
|
|
this.broadcastingError = null;
|
|
|
|
const resp = await this.restService.stopBroadcasting();
|
|
|
|
console.log('Broadcasting response ', resp);
|
2022-12-23 16:17:04 +01:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2023-02-17 17:03:15 +01:00
|
|
|
this.broadcastingError = error.message || error;
|
2022-12-23 16:17:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-22 12:42:02 +02:00
|
|
|
async onStartRecordingClicked() {
|
|
|
|
console.warn('START RECORDING CLICKED');
|
|
|
|
try {
|
|
|
|
await this.restService.startRecording(this.sessionId);
|
|
|
|
} catch (error) {
|
|
|
|
this.recordingError = error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async onStopRecordingClicked() {
|
|
|
|
console.warn('STOP RECORDING CLICKED');
|
|
|
|
try {
|
|
|
|
this.recordingList = await this.restService.stopRecording(this.sessionId);
|
|
|
|
console.log('RECORDING LIST ', this.recordingList);
|
|
|
|
} catch (error) {
|
|
|
|
this.recordingError = error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async onDeleteRecordingClicked(recordingId: string) {
|
|
|
|
console.warn('DELETE RECORDING CLICKED');
|
|
|
|
|
|
|
|
try {
|
|
|
|
this.recordingList = await this.restService.deleteRecording(recordingId);
|
|
|
|
} catch (error) {
|
|
|
|
this.recordingError = error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-04 16:24:42 +01:00
|
|
|
private async requestForTokens() {
|
|
|
|
const response = await this.restService.getTokensFromBackend(this.sessionId);
|
|
|
|
this.recordingList = response.recordings;
|
|
|
|
this.tokens = {
|
|
|
|
webcam: response.cameraToken,
|
|
|
|
screen: response.screenToken
|
|
|
|
};
|
|
|
|
|
|
|
|
console.log('Token requested: ', this.tokens);
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|