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);
}
}
}
+32 -21
View File
@@ -282,14 +282,25 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
});
}
startRecording() {
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();
}
stopRecording() {
@@ -1021,42 +1032,42 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
this.downloadFileMsg(msg)
/* } else if (msg.file.type === "application/pdf") {
console.log(str);
const win = window.open("", "_blank");
let html = '';
html += '<html>';
html += '<body style="margin:0!important">';
html += '<iframe width="100%" height="100%" src="' + str + '" type="application/pdf" />';
html += '</body>';
html += '</html>';
setTimeout(() => {
win.document.write(html);
}, 0); */
//this.viewDocument(msg, msg.attachments.image_url)
} 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)
} else if (this.platform.is('tablet')) {
this.openFile(str, msg.attachments[0].name, msg.file.type);
}
}
}