Commit 421d5468 authored by liujiaxin's avatar liujiaxin

feat: add audio record

parent 4ca5d838
...@@ -184,6 +184,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -184,6 +184,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
case HttpEventType.UploadProgress: case HttpEventType.UploadProgress:
this.zone.run(() => { this.zone.run(() => {
this.progress = Math.floor(100 * event.loaded / event.total); this.progress = Math.floor(100 * event.loaded / event.total);
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}); });
break; break;
case HttpEventType.Response: case HttpEventType.Response:
...@@ -191,6 +194,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -191,6 +194,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
console.log(event); console.log(event);
this.audioUploaded.emit(event.body); this.audioUploaded.emit(event.body);
this.isUploading = false; this.isUploading = false;
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}); });
break; break;
} }
...@@ -228,11 +234,17 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -228,11 +234,17 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
onBtnClearAudio() { onBtnClearAudio() {
this.audioUrl = null; this.audioUrl = null;
this.audioRemoved.emit(); this.audioRemoved.emit();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
} }
onBtnDeleteAudio() { onBtnDeleteAudio() {
this.audioUrl = null; this.audioUrl = null;
this.audioRemoved.emit(); this.audioRemoved.emit();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
} }
handleChange(info: { type: string, file: UploadFile, event: any }): void { handleChange(info: { type: string, file: UploadFile, event: any }): void {
...@@ -250,6 +262,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -250,6 +262,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.progress = parseInt(info.event.percent, 10); this.progress = parseInt(info.event.percent, 10);
break; break;
} }
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
} }
checkSelectFile(file: any) { checkSelectFile(file: any) {
if (!file) { if (!file) {
...@@ -281,6 +296,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -281,6 +296,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
this.nzMessageService.info('Upload Success'); this.nzMessageService.info('Upload Success');
this.isUploading = false; this.isUploading = false;
this.audioUrl = url; this.audioUrl = url;
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
} }
uploadFailure = (err, file) => { uploadFailure = (err, file) => {
this.isUploading = false; this.isUploading = false;
...@@ -290,6 +308,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -290,6 +308,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
console.log(err); console.log(err);
this.nzMessageService.error('Upload Error ' + err.message); this.nzMessageService.error('Upload Error ' + err.message);
this.audioUploadFailure.emit(file); this.audioUploadFailure.emit(file);
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
} }
doProgress = (p) => { doProgress = (p) => {
if (p > 1) { if (p > 1) {
...@@ -300,6 +321,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy { ...@@ -300,6 +321,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
} }
// console.log(Math.floor(p * 100)); // console.log(Math.floor(p * 100));
this.progress = Math.floor(p * 100); this.progress = Math.floor(p * 100);
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment