CC3.1.1 Bug Audio plays double on first time – #6 by system – Cocos Creator


Hello, here is a video demonstrating the problem

The top button just play the audio in this simple way for testing:
image

The second button goes through a custom audio manager with key->clip, but the hook is like this:

UIClickSFX.ts

    onLoad() {        
        this.node.on(Button.EventType.CLICK, this.onclick, this);
    }

    onclick() {
        if (this.key)
            AudioManager.instance?.playByKey(this.key);
    }

In AudioManager.ts the playByKey just finds the clip and at the end call this:

    public playOneShot(clip: AudioClip, volumeScale = 1) {
        if (!this.isAudioEnabled)
            return;
        if (!clip)
            return;
        if (this.source)
            this.source.playOneShot(clip, volumeScale);
        else
            logger.log(`ERROR: AudioSource is null`);
    }

Hope that these extra info help



Source link

More To Explore

Why I care about a moonshot for care

I love the idea of moonshots. There is something stirring and hopeful in the conception of setting a venture for change or accomplishment whose virtue

Share on facebook
Share on twitter
Share on linkedin
Share on email