This commit is contained in:
tiago.kayaya
2022-04-07 15:22:25 +01:00
parent 6a0ef4cb26
commit 647f5dcd3b
3 changed files with 78 additions and 49 deletions
@@ -300,15 +300,25 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
startRecording() {
console.log('Recording');
if (this.recording) {
return;
async startRecording() {
if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){
if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){
//if(await this.hasAudioRecordingPermission()){
if (this.recording) {
return;
}
this.recording = true;
VoiceRecorder.startRecording();
this.calculateDuration();
//}
}
else{
this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.');
}
}
else{
this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!');
}
this.recording = true;
VoiceRecorder.startRecording();
this.calculateDuration();
}
@@ -1076,14 +1086,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
} else {
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
this.downloadFileMsg(msg)
} else {
var str = msg.attachments[0].image_url;
str = str.substring(1, ((str.length) - 1));
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.downloadFileFromBrowser(msg.attachments[0].name, str)
/* const modal = await this.modalController.create({
component: ViewMediaPage,
@@ -1096,7 +1106,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
});
modal.present(); */
} else {
this.openFile(str, msg.attachments[0].name);
}
+23 -15
View File
@@ -237,17 +237,25 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
startRecording() {
console.log('Recording');
if (this.recording) {
return;
async startRecording() {
if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){
if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){
//if(await this.hasAudioRecordingPermission()){
if (this.recording) {
return;
}
this.recording = true;
VoiceRecorder.startRecording();
this.calculateDuration();
//}
}
else{
this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.');
}
}
else{
this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!');
}
this.recording = true;
VoiceRecorder.startRecording()
.then((result: GenericResponse) => console.log(result.value))
.catch(error => console.log(error));
this.calculateDuration();
}
stopRecording() {
@@ -990,13 +998,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
this.downloadFileMsg(msg)
//this.testDownlod(msg)
} else {
var str = msg.attachments[0].image_url;
str = str.substring(1, ((str.length) - 1));
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.downloadFileFromBrowser(msg.attachments[0].name, str)
/* const modal = await this.modalController.create({
component: ViewMediaPage,
@@ -1009,11 +1017,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
});
modal.present(); */
} else {
this.openFile(str, msg.attachments[0].name, msg.file.type);
}
}
}