Commit c9f6b7c7 authored by limingzhe's avatar limingzhe

fix: debug

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