Commit c9f6b7c7 authored by limingzhe's avatar limingzhe

fix: debug

parent dda2d29b
No preview for this file type
...@@ -469,13 +469,19 @@ cc.Class({ ...@@ -469,13 +469,19 @@ cc.Class({
this.progressBtn.on('touchstart', (e) => {}); this.progressBtn.on('touchstart', (e) => {});
let audioClip; let audioClip;
let totalTimeAudioId;
cc.assetManager.loadRemote(this.data.audio_url, (err, _audioClip) => { cc.assetManager.loadRemote(this.data.audio_url, (err, _audioClip) => {
audioClip = _audioClip; audioClip = _audioClip;
this.totalTime = audioClip.duration; this.totalTime = audioClip.duration;
totalTimeLabel.string = this.formatTime(this.totalTime * 1000);
if (!this.totalTime) {
totalTimeAudioId = cc.audioEngine.play(audioClip, false, 0);
checkHasDuration();
}
this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
checkIsPlaying();
// setTimeout(() => { // setTimeout(() => {
// if (this.isDestroy) { // if (this.isDestroy) {
...@@ -488,13 +494,13 @@ cc.Class({ ...@@ -488,13 +494,13 @@ cc.Class({
const checkIsPlaying = () => { const checkHasDuration = () => {
const timerId = setTimeout(() => { setTimeout(() => {
console.log(' in checkIsPlaying 1') console.log(' in checkIsPlaying 1')
if (this.audioId == null) { if (totalTimeAudioId == null) {
return; return;
} }
...@@ -502,24 +508,12 @@ cc.Class({ ...@@ -502,24 +508,12 @@ cc.Class({
return; return;
} }
const curTime = cc.audioEngine.getCurrentTime(this.audioId); let duration = cc.audioEngine.getDuration(totalTimeAudioId);
if (curTime) {
let duration = cc.audioEngine.getDuration(audioId);
console.log('curTime: ' + curTime);
console.log('duration: ' + duration);
console.log('audioClip.duration: ' + audioClip.duration);
if (!duration) { if (duration) {
duration = audioClip.duration || 0;
}
// if (!duration) {
// checkIsPlaying();
// return;
// }
cc.audioEngine.stop(this.audioId); cc.audioEngine.stop(totalTimeAudioId);
this.totalTime = duration; this.totalTime = duration;
totalTimeLabel.string = this.formatTime(duration * 1000); totalTimeLabel.string = this.formatTime(duration * 1000);
...@@ -528,7 +522,7 @@ cc.Class({ ...@@ -528,7 +522,7 @@ cc.Class({
checkIsPlaying(); checkIsPlaying();
} }
}, 1); }, 300);
} }
......
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