Commit a19b27ac authored by limingzhe's avatar limingzhe
parents 3ebf9844 b68f5171
......@@ -10,7 +10,7 @@
Record Audio
</div>
<nz-upload
[nzAccept] = "'.mp3'"
[nzAccept] = "'.mp3,.m4a,.wav,.ogg'"
[nzShowUploadList]="false"
[nzAction]="uploadUrl"
[nzData]="uploadData"
......
......@@ -214,7 +214,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
case 'success':
this.isUploading = false;
let url = info.file.response.url;
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3";
// 保留原始文件格式,只添加_l前缀
url = this.replaceAudioUrl(url);
info.file.response.url = url;
this.uploadSuccess(info.file.response);
this.audioUploaded.emit(info.file.response);
......@@ -225,13 +226,20 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
break;
}
}
replaceAudioUrl(url: string) {
const ext = url.substring(url.lastIndexOf(".")).toLowerCase();
if(ext === ".mp3") {
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3";
}
return url;
}
checkSelectFile(file: any) {
if (!file) {
return;
}
const isAudio = ['audio/mp3', 'audio/wav', 'audio/ogg'].includes(file.type);
const isAudio = ['audio/mp3', 'audio/wav', 'audio/ogg', 'audio/m4a', 'audio/x-m4a'].includes(file.type);
if (!isAudio) {
this.nzMessageService.error('You can only upload Audio file ( mp3 | wav |ogg)');
this.nzMessageService.error('You can only upload Audio file ( mp3 | wav | ogg | m4a )');
return;
}
const delta = 25;
......@@ -277,7 +285,8 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
}
linkInputed (url, name) {
url = url.substring(0, url.lastIndexOf(".")) + "_l.mp3";
url = this.replaceAudioUrl(url);
this.audioUrl = url;
this.audioUploaded.emit({url});
this.audioName.emit(name);
......@@ -298,7 +307,7 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
if (url.indexOf("teach")<0 || url.indexOf("cdn")<0) {
return;
}
const white = [".mp3"];
const white = [".mp3", ".m4a", ".wav", ".ogg"];
if (!white.includes(url.substr(url.lastIndexOf(".")))) {
return;
}
......
......@@ -102,10 +102,10 @@
</span>
<div style="width: auto; display: flex; align-items: center;">
<label style="margin-right: 10px; font-size: 14px;">
<input type="radio" [(ngModel)]="word.displayType" [value]="1" (change)="save()"> 词卡单词
<input type="radio" [(ngModel)]="word.displayType" [value]="1" (change)="save()" [name]="'displayType_' + i"> 词卡单词
</label>
<label style="font-size: 14px;">
<input type="radio" [(ngModel)]="word.displayType" [value]="3" (change)="save()"> 核心单词
<input type="radio" [(ngModel)]="word.displayType" [value]="3" (change)="save()" [name]="'displayType_' + i"> 核心单词
</label>
</div>
</div>
......
......@@ -31,10 +31,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
'art.',
'num.',
'abbr.',
'verb phrase',
'noun phrase',
'prep phrase',
'phrase',
'ordinal number',
'det.'
];
// 存储courseId
......
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