Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc.audioEngine.playEffect returning null but is playing anyways #3556

Open
milomartinez opened this issue Jun 12, 2018 · 1 comment
Open

Comments

@milomartinez
Copy link

Hi , i just found out that if the audio (mp3 in my case) is playing using cc.audioEngine.playEffect when the loading hasn't finished, the sound will play but retuning null as an audio id, the problem is when the sound is playing in a loop, amd there no sound id to stop it.
any thouhgt??
cheers

@hoanghiep271295
Copy link

The very easy way to fix this problem, if you check audioId is null or underfined please call cc.audioEngine.stopAllEffects();
-- declare

slot.SoundManager = cc.Class.extend({
    ctor: function () {
    },
    soundEffect: function (url, loop) {
        var audioId = cc.audioEngine.playEffect(url, loop);
        return audioId;
    },
    stopAllEffect: function () {
        cc.audioEngine.stopAllEffects();
    },
    stopEffectByID: function (id) {
        cc.audioEngine.stopEffect(id);
    }
});

--- in use

if (this.audioId) {
           this.soundManager.stopEffectByID(this.audioId);
       } else {
           this.soundManager.stopAllEffect();
       }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants