Merge pull request #3562 from NoelDeMartin/MOBILE-2314
MOBILE-2314 fileuploader: Catch errors in recorder
This commit is contained in:
		
						commit
						579057ddf8
					
				| @ -93,32 +93,48 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C | |||||||
|      * Start recording. |      * Start recording. | ||||||
|      */ |      */ | ||||||
|     async startRecording(): Promise<void> { |     async startRecording(): Promise<void> { | ||||||
|         const media = await this.createMedia(); |         try { | ||||||
|  |             const media = await this.createMedia(); | ||||||
| 
 | 
 | ||||||
|         this.media$.next(media); |             this.media$.next(media); | ||||||
| 
 | 
 | ||||||
|         media.recorder.start(); |             media.recorder.start(); | ||||||
|  |         } catch (error) { | ||||||
|  |             CoreDomUtils.showErrorModal(error); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Stop recording. |      * Stop recording. | ||||||
|      */ |      */ | ||||||
|     stopRecording(): void { |     stopRecording(): void { | ||||||
|         this.media$.value?.recorder.stop(); |         try { | ||||||
|  |             this.media$.value?.recorder.stop(); | ||||||
|  |         } catch (error) { | ||||||
|  |             CoreDomUtils.showErrorModal(error); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Stop recording. |      * Stop recording. | ||||||
|      */ |      */ | ||||||
|     pauseRecording(): void { |     pauseRecording(): void { | ||||||
|         this.media$.value?.recorder.pause(); |         try { | ||||||
|  |             this.media$.value?.recorder.pause(); | ||||||
|  |         } catch (error) { | ||||||
|  |             CoreDomUtils.showErrorModal(error); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Stop recording. |      * Stop recording. | ||||||
|      */ |      */ | ||||||
|     resumeRecording(): void { |     resumeRecording(): void { | ||||||
|         this.media$.value?.recorder.resume(); |         try { | ||||||
|  |             this.media$.value?.recorder.resume(); | ||||||
|  |         } catch (error) { | ||||||
|  |             CoreDomUtils.showErrorModal(error); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -143,15 +159,19 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent<C | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const fileName = await CoreFile.getUniqueNameInFolder(CoreFileProvider.TMPFOLDER, 'recording.mp3'); |         try { | ||||||
|         const filePath = CorePath.concatenatePaths(CoreFileProvider.TMPFOLDER, fileName); |             const fileName = await CoreFile.getUniqueNameInFolder(CoreFileProvider.TMPFOLDER, 'recording.mp3'); | ||||||
|         const fileEntry = await CoreFile.writeFile(filePath, this.recording.blob); |             const filePath = CorePath.concatenatePaths(CoreFileProvider.TMPFOLDER, fileName); | ||||||
|  |             const fileEntry = await CoreFile.writeFile(filePath, this.recording.blob); | ||||||
| 
 | 
 | ||||||
|         this.close({ |             this.close({ | ||||||
|             name: fileEntry.name, |                 name: fileEntry.name, | ||||||
|             fullPath: fileEntry.toURL(), |                 fullPath: fileEntry.toURL(), | ||||||
|             type: 'audio/mpeg', |                 type: 'audio/mpeg', | ||||||
|         }); |             }); | ||||||
|  |         } catch (error) { | ||||||
|  |             CoreDomUtils.showErrorModal(error); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user