mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
save
This commit is contained in:
@@ -36,6 +36,7 @@ import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, Cur
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { MessageService } from 'src/app/services/chat/message.service';
|
||||
import { AlertController } from '@ionic/angular';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
@@ -85,6 +86,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
durationDisplay = '';
|
||||
duration = 0;
|
||||
showAvatar = true;
|
||||
audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null
|
||||
|
||||
constructor(
|
||||
private menu: MenuController,
|
||||
@@ -111,6 +113,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private processesService: ProcessesService,
|
||||
private CameraService: CameraService,
|
||||
private sanitiser: DomSanitizer,
|
||||
private alertController: AlertController
|
||||
) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
@@ -296,15 +299,49 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
startRecording() {
|
||||
console.log('Recording');
|
||||
async checkAudioPermission() {
|
||||
const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any)
|
||||
|
||||
console.log('permission', permissionStatus.state); // granted, denied, prompt
|
||||
|
||||
if (this.recording) {
|
||||
return;
|
||||
this.audioPermissionStatus = permissionStatus.state
|
||||
|
||||
permissionStatus.onchange = (data : any) => {
|
||||
// console.log("Permission changed to " + data.state);
|
||||
// console.log('permission', permissionStatus.state); // granted, denied, prompt
|
||||
}
|
||||
this.recording = true;
|
||||
VoiceRecorder.startRecording();
|
||||
this.calculateDuration();
|
||||
|
||||
}
|
||||
|
||||
async startRecording() {
|
||||
|
||||
await this.checkAudioPermission();
|
||||
|
||||
if(this.audioPermissionStatus == 'granted') {
|
||||
if (this.recording) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.recording = true;
|
||||
VoiceRecorder.startRecording();
|
||||
this.calculateDuration();
|
||||
} else {
|
||||
|
||||
const alertPopup = await this.alertController.create({
|
||||
cssClass: 'my-custom-class',
|
||||
header: 'Necessita de permissão para gravar áudio',
|
||||
buttons: [{
|
||||
text: 'Ok',
|
||||
handler: () => {
|
||||
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
await alertPopup.present();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user