Merge pull request #3562 from NoelDeMartin/MOBILE-2314

MOBILE-2314 fileuploader: Catch errors in recorder
main
Dani Palou 2023-02-23 12:59:03 +01:00 committed by GitHub
commit 579057ddf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 14 deletions

View File

@ -93,32 +93,48 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C
* Start recording.
*/
async startRecording(): Promise<void> {
try {
const media = await this.createMedia();
this.media$.next(media);
media.recorder.start();
} catch (error) {
CoreDomUtils.showErrorModal(error);
}
}
/**
* Stop recording.
*/
stopRecording(): void {
try {
this.media$.value?.recorder.stop();
} catch (error) {
CoreDomUtils.showErrorModal(error);
}
}
/**
* Stop recording.
*/
pauseRecording(): void {
try {
this.media$.value?.recorder.pause();
} catch (error) {
CoreDomUtils.showErrorModal(error);
}
}
/**
* Stop recording.
*/
resumeRecording(): void {
try {
this.media$.value?.recorder.resume();
} catch (error) {
CoreDomUtils.showErrorModal(error);
}
}
/**
@ -143,6 +159,7 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C
return;
}
try {
const fileName = await CoreFile.getUniqueNameInFolder(CoreFileProvider.TMPFOLDER, 'recording.mp3');
const filePath = CorePath.concatenatePaths(CoreFileProvider.TMPFOLDER, fileName);
const fileEntry = await CoreFile.writeFile(filePath, this.recording.blob);
@ -152,6 +169,9 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C
fullPath: fileEntry.toURL(),
type: 'audio/mpeg',
});
} catch (error) {
CoreDomUtils.showErrorModal(error);
}
}
/**