Skip to content

Any tips for implementing playlist type functionality? #27

Description

@jagthedrummer

I've implemented a rough play queue and it mostly works, but there are a couple of things that I'm not sure how to address and I'm wondering if anybody has done something similar.

I basically have an array representing sounds that should be played next. When an identifier is added to the queue I pre-emptively call stereo.load(newIdentifier) so that the sound will be ready when it comes time to play it. And the sound that is returned is added to the array. (If we're not already playing something when something is added to the queue it's played immediately.)

My queue service registers a listener for the audio-ended event, and when it fires it checks to see if there's anything in the queue waiting to be played. If so it pulls the first item in the array (which is a sound) and then calls sound.play().

This mostly works, but there are two issues that I'm hoping to solve.

  1. Even when this is working at it's best there is a slight but perceptible delay between the end of one track and the beginning of the next track.
  2. Sometimes, and especially often in mobile Safari, when I call sound.play() on a pre-loaded sound it seems to re-load the sound.

Are there any best practices around this sort of thing?

Thanks in advance! (I realize this may be uncharted territory, so no worries if I'm on my own.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions