Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pausing while loading with autoplay not working #659

Closed
Stenerson opened this issue Nov 27, 2016 · 1 comment
Closed

Pausing while loading with autoplay not working #659

Stenerson opened this issue Nov 27, 2016 · 1 comment

Comments

@Stenerson
Copy link
Contributor

If howler receives a call to pause() before the audio is loaded it puts the command into the internal queue to be run after loading has completed. The issue is that autoplay is checked and acted upon after the queue has been unloaded. This means that the audio will be paused (even though it hasn't started yet) then it will be played.

Here's a jsbin that will show it. I picked a pretty big audio file from WikiCommons. It takes about 2.5 seconds for it to load on my unthrottled network connection. When I call pause() while it's loading it will not pause. When I call pause() after the file has loaded (5 seconds in my case) it does pause correctly.

There are two places in the howler.js core source that have the following pattern.

    // Fire the loaded event.
    if (self._state !== 'loaded') {
      self._state = 'loaded';
      self._emit('load');
      self._loadQueue(); // <-- Going to call pause() in here...
    }

    // Begin playback if specified.
    if (self._autoplay) {
      self.play(); // <-- Then autoplay
    }

Is it intentional to check autoplay after the queue is unloaded? One benefit I can think of is that your volume, position, etc. will be set before playing but I think you can accomplish all of this on initial load with options.

If this is not intentional, I'd be happy to open a pull request that checks autoplay before going through the queue. Alternatively, maybe autoplay should just add a play action to the front(?) of the queue?

@goldfire
Copy link
Owner

goldfire commented Dec 4, 2016

Thanks for catching this! It wasn't intentional, it was overlooked when the queue system was added. It probably makes most sense to add it to the start of the queue, which I'll get added into v2.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants