Commit 9d647fe5 authored by Chen Jiping's avatar Chen Jiping

feat:增加音频清除功能,调整播放逻辑

parent 6911a141
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
(audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl1')"> (audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl1')">
</app-audio-recorder> </app-audio-recorder>
</nz-form-control> </nz-form-control>
<nz-form-control [nzSpan]="2">
<button nz-button nzType="danger" (click)="deleteAudio(item, 'guideAudioUrl1')">
<i nz-icon nzType="delete" nzTheme="outline"></i>清除
</button>
</nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="2" nzFor="guideAudioUrl2">待机音频</nz-form-label> <nz-form-label [nzSpan]="2" nzFor="guideAudioUrl2">待机音频</nz-form-label>
...@@ -30,6 +35,11 @@ ...@@ -30,6 +35,11 @@
(audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl2')"> (audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl2')">
</app-audio-recorder> </app-audio-recorder>
</nz-form-control> </nz-form-control>
<nz-form-control [nzSpan]="2">
<button nz-button nzType="danger" (click)="deleteAudio(item, 'guideAudioUrl2')">
<i nz-icon nzType="delete" nzTheme="outline"></i>清除
</button>
</nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="2" nzFor="guideAudioUrl3">结束音频</nz-form-label> <nz-form-label [nzSpan]="2" nzFor="guideAudioUrl3">结束音频</nz-form-label>
...@@ -38,6 +48,11 @@ ...@@ -38,6 +48,11 @@
(audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl3')"> (audioUploaded)="onAudioUploadSuccess($event, item, 'guideAudioUrl3')">
</app-audio-recorder> </app-audio-recorder>
</nz-form-control> </nz-form-control>
<nz-form-control [nzSpan]="2">
<button nz-button nzType="danger" (click)="deleteAudio(item, 'guideAudioUrl3')">
<i nz-icon nzType="delete" nzTheme="outline"></i>清除
</button>
</nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="2">图片</nz-form-label> <nz-form-label [nzSpan]="2">图片</nz-form-label>
......
...@@ -99,6 +99,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -99,6 +99,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save(); this.save();
} }
deleteAudio(item, key){
item[key] = null;
this.save();
}
/** /**
* 储存数据 * 储存数据
......
...@@ -219,26 +219,21 @@ cc.Class({ ...@@ -219,26 +219,21 @@ cc.Class({
this._cantouch = false; this._cantouch = false;
//播放动画
this.playAni('begin', 0);
const begin = () => {
this.playAni('begin', 0);
this._cantouch = true;
this.begin();
}
console.log(this.data.guideAudioUrl1); console.log(this.data.guideAudioUrl1);
//如果有引导音频,则播放完引导音频再开始 //如果有引导音频,则播放完引导音频再开始
if (this.data.guideAudioUrl1) { if (this.data.guideAudioUrl1) {
//播放动画
this.playAni('begin', 0);
//播放引导音频1 //播放引导音频1
this.playAudioByUrl(this.data.guideAudioUrl1, () => { this.playAudioByUrl(this.data.guideAudioUrl1, () => {
begin(); this.begin();
}); });
} }
else { else {
begin(); this.begin();
} }
this.addDefaultMusic(); this.addDefaultMusic();
...@@ -661,6 +656,8 @@ cc.Class({ ...@@ -661,6 +656,8 @@ cc.Class({
this.playAudioByUrl(this.data.exercises.audioUrl, () => { this.playAudioByUrl(this.data.exercises.audioUrl, () => {
this._cantouch = true;
//停止监听动画 //停止监听动画
this._stopAni = true; this._stopAni = true;
...@@ -749,14 +746,7 @@ cc.Class({ ...@@ -749,14 +746,7 @@ cc.Class({
handNode.opacity = 0; handNode.opacity = 0;
this._stop = true; this._stop = true;
//播放动画 const play = () =>{
const state = this.playAni('finish', 0);
//播放结束音频
this.playAudioByUrl(this.data.guideAudioUrl3, () => {
state.stop();
this.playAni('normal', 0); this.playAni('normal', 0);
//设置可以点击字母 //设置可以点击字母
...@@ -767,9 +757,23 @@ cc.Class({ ...@@ -767,9 +757,23 @@ cc.Class({
this._canClickCat = true; this._canClickCat = true;
this.showPhotoBtn(); this.showPhotoBtn();
}); }
if(this.data.guideAudioUrl3){
//播放动画
const state = this.playAni('finish', 0);
//播放结束音频
this.playAudioByUrl(this.data.guideAudioUrl3, () => {
state.stop();
play();
});
}
else{
play();
}
}, },
......
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