Commit 948e5ee0 authored by 范雪寒's avatar 范雪寒

fix: 不上传音频的时候,不显示播放器

parent e942b39d
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
} "cli": {
"analytics": false
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -88,6 +88,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -88,6 +88,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, key) {
this.item[key] = e.url; this.item[key] = e.url;
// this.item[key] = '';
this.save(); this.save();
} }
...@@ -98,6 +99,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -98,6 +99,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/ */
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any> window).courseware.setData(this.item, null, this.saveKey);
console.log('this.item = ' + JSON.stringify(this.item));
this.refresh(); this.refresh();
} }
......
...@@ -448,9 +448,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -448,9 +448,9 @@ export class PlayComponent implements OnInit, OnDestroy {
]; ];
} }
if (!this.data.audio_url) { // if (!this.data.audio_url) {
this.data.audio_url = 'assets/play/default/audio.mp3'; // this.data.audio_url = 'assets/play/default/audio.mp3';
} // }
} }
...@@ -467,7 +467,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -467,7 +467,9 @@ export class PlayComponent implements OnInit, OnDestroy {
initAudio() { initAudio() {
// 音频资源 // 音频资源
this.addUrlToAudioObj(this.data.audio_url); if (this.data.audio_url) {
this.addUrlToAudioObj(this.data.audio_url);
}
...@@ -585,6 +587,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -585,6 +587,7 @@ export class PlayComponent implements OnInit, OnDestroy {
mapDown(event) { mapDown(event) {
if (!this.canTouch) { if (!this.canTouch) {
return; return;
} }
...@@ -600,15 +603,19 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -600,15 +603,19 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
if (this.checkClickTarget(this.progressBarBg)) { if (this.progressBarBg){
this.isClickedProgress = true; if (this.checkClickTarget(this.progressBarBg)) {
this.touchDownProgressBar(this.progressBarBg); this.isClickedProgress = true;
return; this.touchDownProgressBar(this.progressBarBg);
return;
}
} }
if (this.checkClickTarget(this.curAudio.playBtn)) { if (this.curAudio) {
this.touchDownAudioBtn(this.curAudio); if (this.checkClickTarget(this.curAudio.playBtn)) {
return; this.touchDownAudioBtn(this.curAudio);
return;
}
} }
this.sentences.forEach((sentence) => { this.sentences.forEach((sentence) => {
...@@ -724,6 +731,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -724,6 +731,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
private initAudioPlayer() { private initAudioPlayer() {
if (!this.data.audio_url) {
return;
}
this.curAudio = this.audioObj[this.data.audio_url]; this.curAudio = this.audioObj[this.data.audio_url];
this.curAudio.onended = () => { this.curAudio.onended = () => {
this.setAudioState(this.curAudio, false); this.setAudioState(this.curAudio, false);
...@@ -864,6 +874,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -864,6 +874,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
private updateTime() { private updateTime() {
if (!this.curAudio) {
return;
}
if (!this.isClickedProgress) { if (!this.isClickedProgress) {
const progress = this.curAudio.currentTime / this.curAudio.duration; const progress = this.curAudio.currentTime / this.curAudio.duration;
this.setAudioProgress(this.progressBarBg, progress); this.setAudioProgress(this.progressBarBg, progress);
......
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