[SOLVED] Resuming a sound slot after pausing it will playback from the start

I want to pause a sound in a sound slot and resume playback from where it was paused. I think this is suppose to be the normal behavior. But instead of resuming the audio track from where it was paused, it start from the beginning. I did a small and clean public project if someone wants to take a look at my current code:

https://playcanvas.com/project/521663/overview/pauseresume-audio-test

I’m probably doing something wrong.

Here’s the code:

var PauseResumeAudioTest = pc.createScript('pauseResumeAudioTest');

PauseResumeAudioTest.attributes.add('audioTrack', {
    type: 'entity',
});

// initialize code called once per entity
PauseResumeAudioTest.prototype.initialize = function() {
    
};

// update code called every frame
PauseResumeAudioTest.prototype.update = function(dt) {
    if (this.app.keyboard.isPressed(pc.KEY_P)) {
        if(this.audioTrack && this.audioTrack.sound.slot("Slot 1").isPaused === true){
            this.audioTrack.sound.slot("Slot 1").resume();
        }
    } else {
        if(this.audioTrack && this.audioTrack.sound.slot("Slot 1").isPaused === false){
            this.audioTrack.sound.slot("Slot 1").pause();
        }
    }
};

Hello,

This is a bug - we found the issue and will fix as soon as possible. Thanks for reporting.

We pushed a fix to the master branch of the engine. Can you give it a test by appending this parameter in the URL when you launch your application?

?use_local_engine=https://code.playcanvas.com/playcanvas-latest.js

1 Like

I’ve tested it on the public project linked in my first post and on the private and more elaborate one I’m currently working on. It’s working and awesome in both.

Thanks you vaios for this quick answer and fix!

How will I know when to stop appending the URL parameter you gave me?

Hopefully we can deploy this tomorrow I’ll let you know once it’s done.

The fixes are now deployed so you don’t need to use that URL parameter anymore.

Excellent! Thanks for you help I really appreciated it!