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

How to prevent react-howler from creating a new instance of the same song while the previous one is still playing when updating the seek? #133

Open
barackm opened this issue Apr 9, 2022 · 6 comments

Comments

@barackm
Copy link

barackm commented Apr 9, 2022

I am trying to create an audio player, I have been following the documentation here for the full control example,
However, when I try to update the seek of the player with my range input, the same song starts playing from the beginning while the previous one is still playing.

Here are the methods I use to manage the player seek

  // called on the onChange event
  handleSeekingChange = (e) => {
    this.setState({
      currentTime: parseFloat(e.target.value),
    });
  };
// called on the onMouseDown event
 handleMouseDownSeek = () => {
    this.setState({
      isSeeking: true,
    });
  };
 // called on the onMouseUp
  handleMouseUpSeek = (e) => {
    this.setState({
      isSeeking: false,
    });
    this.player.seek(e.target.value);
  };
  renderSeekPos = () => {
    const { states } = this.props;
    const { isSeeking } = this.state;
    const { isPlaying } = states;
    if (!isSeeking) {
      this.setState({
        currentTime: this.player.seek(),
      });
    }
    if (isPlaying) {
      this._raf = raf(this.renderSeekPos);
    }
  };
@barackm barackm changed the title How to prevent react-howler from creating a new instance with the same song while the previous one is still playing when updating the seek? How to prevent react-howler from creating a new instance of the same song while the previous one is still playing when updating the seek? Apr 9, 2022
@Stenerson
Copy link
Collaborator

Hi @barackm, Can you include the rest of your component's code or, better yet, reproduce in a simple, stripped-down, example and include that code?

My hunch is that you're accidentally creating a new instance of react-howler somewhere or some state's not getting updated like you're expecting.

@ovionlogis
Copy link

faced the same problem, I'm sure it's related to this goldfire/howler.js#1163

@wasifhyder
Copy link

Could be caused by a song that's not fully loaded. Since you're buffering the song (assuming the file is very large). This kind of error occurs when you try to load a part of the song that's not loaded yet.

@phemartin
Copy link

I'm having the same issue. Is there a way to prevent this issue?

@thecooltechguy
Copy link

also facing this issue :((

@gavinnwang
Copy link

Having the same problem..

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

7 participants