Commit d4a11193 authored by Chen Jiping's avatar Chen Jiping

feat:增加音频名显示,并增加音频转换处理

parent 6f6efa65
......@@ -29,7 +29,6 @@
</div>
</div>
<div *ngIf="audioUrl && needRemove; then truthyTemplate else falsyTemplate"></div>
<ng-template #truthyTemplate >
......@@ -45,10 +44,6 @@
<fa-icon icon="cog"></fa-icon>
</div>
</ng-template>
</div>
<div class="p-progress ml-2" (click)="onBtnPlay()" *ngIf="audioUrl || audioBlob">
......@@ -58,4 +53,6 @@
<fa-icon [icon]="playIcon"></fa-icon>
</div>
</div>
<div class="audio-name">{{_audioName}}</div>
</div>
......@@ -103,6 +103,13 @@
}
}
.audio-name{
margin-top: 3.5px;
position: relative;
margin-left: 7px;;
line-height: 26px;
}
:host ::ng-deep nz-upload {
line-height: 33px;
}
......
......@@ -31,6 +31,9 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
@Input()
audioItem: any = null;
@Input()
_audioName: any = null;
@Input()
set audioUrl(url) {
this._audioUrl = url;
......@@ -48,6 +51,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
@Output() audioUploaded = new EventEmitter();
@Output() audioUploadFailure = new EventEmitter();
@Output() audioRemoved = new EventEmitter();
@Output() audioName = new EventEmitter();
percent = 0;
progress = 0;
recorder: any;
......@@ -168,8 +172,12 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
break;
case 'success':
this.isUploading = false;
let url = info.file.response.url;
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3";
info.file.response.url = url;
this.uploadSuccess(info.file.response);
this.audioUploaded.emit(info.file.response);
this.audioName.emit(info.file.name);
break;
case 'progress':
this.progress = parseInt(info.event.percent, 10);
......
......@@ -18,8 +18,8 @@
<nz-form-item>
<nz-form-label [nzSpan]="4">题目音频</nz-form-label>
<nz-form-control [nzSpan]="12">
<app-audio-recorder [audioUrl]="item.questionTextAudio"
(audioUploaded)="onAudioUploadSuccess($event, item, 'questionTextAudio')">
<app-audio-recorder [audioUrl]="item.questionTextAudio" [_audioName]="item.questionTextAudioName"
(audioUploaded)="onAudioUploadSuccess($event, item, 'questionTextAudio')" (audioName)="onAudioName($event, item, 'questionTextAudioName')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
......@@ -34,8 +34,8 @@
<nz-form-item>
<nz-form-label [nzSpan]="4">完整音频</nz-form-label>
<nz-form-control [nzSpan]="12">
<app-audio-recorder [audioUrl]="item.pageAudio"
(audioUploaded)="onAudioUploadSuccess($event, item, 'pageAudio')">
<app-audio-recorder [audioUrl]="item.pageAudio" [_audioName]="item.pageAudioName"
(audioUploaded)="onAudioUploadSuccess($event, item, 'pageAudio')" (audioName)="onAudioName($event, item, 'pageAudioName')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
......@@ -62,8 +62,8 @@
<nz-form-item>
<nz-form-label [nzSpan]="4">音频</nz-form-label>
<nz-form-control [nzSpan]="14">
<app-audio-recorder [audioUrl]="data.audio"
(audioUploaded)="onAudioUploadSuccess($event, data, 'audio')">
<app-audio-recorder [audioUrl]="data.audio" [_audioName]="data.audioName"
(audioUploaded)="onAudioUploadSuccess($event, data, 'audio')" (audioName)="onAudioName($event, data, 'audioName')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
......
......@@ -62,6 +62,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save();
}
if (!this.item.questionTextAudioName) {
this.item.questionTextAudioName = "故事留声机游戏说明.MP3";
this.save();
}
if (!this.item.sentences) {
this.item.sentences = [];
this.save();
......@@ -88,6 +93,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save();
}
onAudioName(e, item, key){
item[key] = e;
this.save();
}
/**
* 储存数据
*/
......
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