Skip to content

Transport-synced Player continues to play after Transport.pause() #1289

@AndreyMay

Description

@AndreyMay

Describe the bug

Transport-synced Player continues to play the full audio loaded into the Player after Transport.pause(). It happens when the Transport.pause() is triggered ~exactly at/near the beginning of Player.sync().start(5) time (i.e. second 5 in this example).

It seems like the event is scheduled and schedule is not cleared in this case. Potentially related to latencyHint timing? (using defaults).

To Reproduce

  1. Create a Player with audio (couple of seconds long)
  2. Sync Player to Transport via .sync().start(5)
  3. Start the Transport and pause around second 5. Try values between 4.9 and 5.1

Expected behavior

When Transport.pause() is called all audio should stop playing.

What I've tried

In Source.ts -> start() I've added a state check before calling _start() and that seem to help.
But maybe it's introducing some other issues as I've noticed now sometimes synced Players ahead on the timeline are not playing (?)

const sched = this.context.transport.schedule((t) => {
    if (this.state === "started") {
       this._start(t, offset, duration);
    } else {
       this.log(">>> [source.start] BLOCKED: transport.state !== 'started':", this.state, t);
    }
}, computedTime); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions