MOBILE-3833 capture: Fix discard in-app audio in device
parent
4aeababbf6
commit
15b6e12b04
|
@ -130,7 +130,27 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy {
|
||||||
* @return Promise resolved when ready.
|
* @return Promise resolved when ready.
|
||||||
*/
|
*/
|
||||||
protected async initCordovaMediaPlugin(): Promise<void> {
|
protected async initCordovaMediaPlugin(): Promise<void> {
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.createFileAndMediaInstance();
|
||||||
|
|
||||||
|
this.readyToCapture = true;
|
||||||
|
this.previewMedia = this.previewAudio?.nativeElement;
|
||||||
|
} catch (error) {
|
||||||
|
this.dismissWithError(-1, error.message || error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a file entry and the cordova media instance.
|
||||||
|
*/
|
||||||
|
protected async createFileAndMediaInstance(): Promise<void> {
|
||||||
this.filePath = this.getFilePath();
|
this.filePath = this.getFilePath();
|
||||||
|
|
||||||
|
// First create the file.
|
||||||
|
this.fileEntry = await CoreFile.createFile(this.filePath);
|
||||||
|
|
||||||
|
// Now create the media instance.
|
||||||
let absolutePath = CoreText.concatenatePaths(CoreFile.getBasePathInstant(), this.filePath);
|
let absolutePath = CoreText.concatenatePaths(CoreFile.getBasePathInstant(), this.filePath);
|
||||||
|
|
||||||
if (Platform.is('ios')) {
|
if (Platform.is('ios')) {
|
||||||
|
@ -138,17 +158,21 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy {
|
||||||
absolutePath = absolutePath.replace(/^file:\/\//, '');
|
absolutePath = absolutePath.replace(/^file:\/\//, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
// First create the file.
|
|
||||||
this.fileEntry = await CoreFile.createFile(this.filePath);
|
|
||||||
|
|
||||||
// Now create the media instance.
|
|
||||||
this.mediaFile = Media.create(absolutePath);
|
this.mediaFile = Media.create(absolutePath);
|
||||||
this.readyToCapture = true;
|
|
||||||
this.previewMedia = this.previewAudio?.nativeElement;
|
|
||||||
} catch (error) {
|
|
||||||
this.dismissWithError(-1, error.message || error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the file and the cordova media instance.
|
||||||
|
*/
|
||||||
|
protected async resetCordovaMediaCapture(): Promise<void> {
|
||||||
|
if (this.filePath) {
|
||||||
|
// Remove old file, don't block the user for this.
|
||||||
|
CoreFile.removeFile(this.filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mediaFile?.release();
|
||||||
|
|
||||||
|
await this.createFileAndMediaInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -410,11 +434,15 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy {
|
||||||
/**
|
/**
|
||||||
* Discard the captured media.
|
* Discard the captured media.
|
||||||
*/
|
*/
|
||||||
discard(): void {
|
async discard(): Promise<void> {
|
||||||
this.previewMedia?.pause();
|
this.previewMedia?.pause();
|
||||||
this.streamVideo?.nativeElement.play();
|
this.streamVideo?.nativeElement.play();
|
||||||
this.audioDrawer?.start();
|
this.audioDrawer?.start();
|
||||||
|
|
||||||
|
if (this.isCordovaAudioCapture) {
|
||||||
|
await this.resetCordovaMediaCapture();
|
||||||
|
}
|
||||||
|
|
||||||
this.hasCaptured = false;
|
this.hasCaptured = false;
|
||||||
this.isCapturing = false;
|
this.isCapturing = false;
|
||||||
this.resetChrono = true;
|
this.resetChrono = true;
|
||||||
|
|
Loading…
Reference in New Issue