mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
save, work in progress!
This commit is contained in:
@@ -40,7 +40,7 @@ import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { FileOpener } from '@ionic-native/file-opener/ngx';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
/* import {Plugins} from '@capacitor/core';
|
||||
|
||||
const { Filesystem } = Plugins; */
|
||||
@@ -88,6 +88,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
storedFileNames = [];
|
||||
lastAudioRecorded = '';
|
||||
audioRecorded:any = "";
|
||||
audioDownloaded:any = "";
|
||||
durationDisplay = '';
|
||||
duration = 0;
|
||||
@ViewChild('recordbtn', { read: ElementRef }) recordBtn: ElementRef;
|
||||
@@ -119,7 +120,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private processesService: ProcessesService,
|
||||
private storage: Storage,
|
||||
private fileToBase64Service: FileToBase64Service,
|
||||
private fileOpener: FileOpener,
|
||||
private sanitiser: DomSanitizer,
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
@@ -131,6 +132,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
};
|
||||
|
||||
console.log(this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({}));
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.wsChatMethodsService.openRoom(this.roomId)
|
||||
@@ -203,6 +206,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log(result);
|
||||
this.storedFileNames = result.files.reverse();
|
||||
this.lastAudioRecorded = this.storedFileNames[0];
|
||||
this.getFile(this.lastAudioRecorded);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -261,7 +265,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log(audioFile);
|
||||
const base64sound = audioFile.data;
|
||||
|
||||
//this.audioRecorded = `data:audio/aac;base64,${base64sound}`;
|
||||
this.audioRecorded = `data:audio/aac;base64,${base64sound}`;
|
||||
|
||||
console.log(this.audioRecorded);
|
||||
|
||||
@@ -269,12 +273,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
const audioRef = new Audio(`data:audio/aac;base64,${base64sound}`)
|
||||
//this.audioRecorded = audioRef;
|
||||
//console.log(audioRef);
|
||||
console.log(audioRef);
|
||||
audioRef.oncanplaythrough = () => audioRef.play();
|
||||
audioRef.load();
|
||||
|
||||
//this.getFile(fileName);
|
||||
|
||||
}
|
||||
|
||||
async getFile(fileName?:any){
|
||||
@@ -298,6 +300,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
|
||||
handlePress(id?: string) {
|
||||
this.selectedMsgId = id;
|
||||
this.showMessageOptions = true;
|
||||
@@ -425,6 +428,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
//Converting base64 to blob
|
||||
const base64 = await fetch(base64sound);
|
||||
const base64Response = await fetch(`data:audio/aac;base64,${base64sound}`);
|
||||
console.log(base64Response);
|
||||
|
||||
const blob = await base64Response.blob();
|
||||
|
||||
console.log(blob);
|
||||
@@ -434,19 +439,20 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": "audio/aac",
|
||||
"type": "aplication/audio",
|
||||
/* "guid": '', */
|
||||
},
|
||||
attachments: [{
|
||||
"title": fileName ,
|
||||
"title_link": base64Response.url,
|
||||
"title_link": `data:audio/aac;base64,${base64sound}`,
|
||||
"title_link_download": true,
|
||||
"type": "file"
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
|
||||
alert('OK')
|
||||
this.allowTyping = true;
|
||||
this.lastAudioRecorded = '';
|
||||
|
||||
}
|
||||
|
||||
@@ -498,6 +504,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/* playSound(url?:any){
|
||||
alert('here')
|
||||
console.log(url);
|
||||
//this.audioDownloaded = this.sanitiser.bypassSecurityTrustResourceUrl(url);
|
||||
this.audioDownloaded = url;
|
||||
} */
|
||||
|
||||
docIndex(index: number) {
|
||||
this.dicIndex = index
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user