Skip to content

create playMode() method for SoundFile #117

Closed

Description

@ogbabydiesal

can be achieved by spinning up more Tone.Player classes internally instead of leaving it up to the user.

Activity

  1. sadSanta-07 commented on Oct 2, 2026

    @sadSanta-07
    Contributor

    Hi @ogbabydiesal! I'd love to work on implementing the playMode() method for SoundFile by managing internal Tone.Player instances. Could you please assign this issue to me?

  2. ogbabydiesal commented on Oct 16, 2026

    @ogbabydiesal
    MemberAuthor

    Hey @sadSanta-07 good work, this is close. i noticed however that the pause method is now broken. in fact it made me realize some weird behavior with pause() in general that I need to address (when the soundfile isn't looping, isPlaying() never returns to false when the soundfile ends - but thats a whole other bug).

    can you take a look at why your pause() method doesn't work?

  3. sadSanta-07 commented on Oct 17, 2026

    @sadSanta-07
    Contributor

    Hi @ogbabydiesal! you were completely right.

    The issue was that setting playbackRate = 0 on pause kept the Tone.Player in a "started" state indefinitely. Because it never naturally stopped, the onstop garbage collection callback never fired, keeping isPlaying() stuck on true and filling up the active players array.

    I've pushed an updated commit that fixes this:

    Fixed pause() and play(): pause() now properly stops the players and saves the exact offset time using the Web Audio context clock. play() checks for this offset and resumes cleanly without overlapping audio.

    Fixed isPlaying(): Because the players are fully stopped on pause (and when they finish), the garbage collection runs properly and isPlaying() accurately returns to false.

    Fixed onended: Added an internal _isStopping flag so manual pauses/stops don't trigger the user's onended callback prematurely; it now only fires on a natural finish.

    Let me know if everything looks good to go now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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